From be45b0a2e66b5d25e03795043b626b1567758290 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 24 Feb 2022 21:41:38 +0000 Subject: [PATCH 001/107] Update model_grid.F90 to read land fraction from orography file. Fixes #123 --- sorc/chgres_cube.fd/model_grid.F90 | 41 +++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/sorc/chgres_cube.fd/model_grid.F90 b/sorc/chgres_cube.fd/model_grid.F90 index 028693f35..ac8bf9ad3 100644 --- a/sorc/chgres_cube.fd/model_grid.F90 +++ b/sorc/chgres_cube.fd/model_grid.F90 @@ -75,6 +75,8 @@ module model_grid type(esmf_field), public :: landmask_target_grid !< land mask target grid - '1' land; !! '0' non-land + type(esmf_field), public :: land_frac_target_grid + !< land fraction, target grid type(esmf_field), public :: latitude_target_grid !< latitude of grid center, target grid type(esmf_field), public :: latitude_s_target_grid @@ -1124,6 +1126,7 @@ subroutine define_target_grid(localpet, npets) integer(esmf_kind_i8), allocatable :: landmask_one_tile(:,:) integer(esmf_kind_i8), allocatable :: seamask_one_tile(:,:) + real(esmf_kind_r8), allocatable :: land_frac_one_tile(:,:) real(esmf_kind_r8), allocatable :: latitude_one_tile(:,:) real(esmf_kind_r8), allocatable :: latitude_s_one_tile(:,:) real(esmf_kind_r8), allocatable :: latitude_w_one_tile(:,:) @@ -1211,6 +1214,14 @@ subroutine define_target_grid(localpet, npets) ! seamask (1 - non-land, 0 -land). Read lat/lon on target grid. !----------------------------------------------------------------------- + print*,"- CALL FieldCreate FOR TARGET GRID LAND FRACTION." + land_frac_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + staggerloc=ESMF_STAGGERLOC_CENTER, & + name="target_grid_landmask", rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", error) + print*,"- CALL FieldCreate FOR TARGET GRID LANDMASK." landmask_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_I8, & @@ -1289,6 +1300,7 @@ subroutine define_target_grid(localpet, npets) call error_handler("IN FieldCreate", error) if (localpet == 0) then + allocate(land_frac_one_tile(i_target,j_target)) allocate(landmask_one_tile(i_target,j_target)) allocate(seamask_one_tile(i_target,j_target)) allocate(latitude_one_tile(i_target,j_target)) @@ -1299,6 +1311,7 @@ subroutine define_target_grid(localpet, npets) allocate(longitude_w_one_tile(ip1_target,j_target)) allocate(terrain_one_tile(i_target,j_target)) else + allocate(land_frac_one_tile(0,0)) allocate(landmask_one_tile(0,0)) allocate(seamask_one_tile(0,0)) allocate(longitude_one_tile(0,0)) @@ -1314,14 +1327,24 @@ subroutine define_target_grid(localpet, npets) if (localpet == 0) then the_file = trim(orog_dir_target_grid) // trim(orog_files_target_grid(tile)) call get_model_mask_terrain(trim(the_file), i_target, j_target, landmask_one_tile, & - terrain_one_tile) - seamask_one_tile = 0 - where(landmask_one_tile == 0) seamask_one_tile = 1 + terrain_one_tile, land_frac_one_tile) + +! seamask_one_tile = 0 ! all land +! where(floor(land_frac_one_tile) == 0) seamask_one_tile = 1 ! at least some water +! landmask_one_tile = 0 ! all water +! where(ceiling(land_frac_one_tile) == 1) landmask_one_tile = 1 ! at least some land + + seamask_one_tile = 0 ! all land + where(landmask_one_tile == 0) seamask_one_tile=1 call get_model_latlons(mosaic_file_target_grid, orog_dir_target_grid, num_tiles_target_grid, tile, & i_target, j_target, ip1_target, jp1_target, latitude_one_tile, & latitude_s_one_tile, latitude_w_one_tile, longitude_one_tile, & longitude_s_one_tile, longitude_w_one_tile) endif + print*,"- CALL FieldScatter FOR TARGET GRID LAND FRACTION. TILE IS: ", tile + call ESMF_FieldScatter(land_frac_target_grid, land_frac_one_tile, rootpet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldScatter", error) print*,"- CALL FieldScatter FOR TARGET GRID LANDMASK. TILE IS: ", tile call ESMF_FieldScatter(landmask_target_grid, landmask_one_tile, rootpet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -1360,6 +1383,7 @@ subroutine define_target_grid(localpet, npets) call error_handler("IN FieldScatter", error) enddo + deallocate(land_frac_one_tile) deallocate(landmask_one_tile) deallocate(seamask_one_tile) deallocate(longitude_one_tile) @@ -1626,7 +1650,7 @@ end subroutine get_cell_corners !! @param [out] mask land mask of tile !! @param [out] terrain terrain height of tile !! @author George Gayno NCEP/EMC - subroutine get_model_mask_terrain(orog_file, idim, jdim, mask, terrain) + subroutine get_model_mask_terrain(orog_file, idim, jdim, mask, terrain, land_frac) use netcdf @@ -1638,6 +1662,7 @@ subroutine get_model_mask_terrain(orog_file, idim, jdim, mask, terrain) integer(esmf_kind_i8), intent(out) :: mask(idim,jdim) real(esmf_kind_i8), intent(out) :: terrain(idim,jdim) + real(esmf_kind_i8), intent(out) :: land_frac(idim,jdim) integer :: error, lat, lon integer :: ncid, id_dim, id_var @@ -1684,6 +1709,14 @@ subroutine get_model_mask_terrain(orog_file, idim, jdim, mask, terrain) call netcdf_err(error, 'reading orog_raw') terrain = dummy + print*,"- READ LAND FRACTION." + error=nf90_inq_varid(ncid, 'land_frac', id_var) + call netcdf_err(error, 'reading land_frac id') + error=nf90_get_var(ncid, id_var, dummy) + call netcdf_err(error, 'reading orog_raw') + land_frac = dummy + +!print*,'land frac ',dummy(idim/2,:) error = nf90_close(ncid) deallocate (dummy) From cbcc5da79c0ca5d5c8da4a33464b50860794fd8d Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 24 Feb 2022 22:25:45 +0000 Subject: [PATCH 002/107] Add new variable to hold sea ice column temperatures. For non-fractional grids, the soil temperature field was used for both land and non-land. Now points can have both land and sea ice. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 20 ++++++++++++++++++++ sorc/chgres_cube.fd/write_data.F90 | 25 ++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index c8cc2961a..25a082933 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -59,6 +59,8 @@ module surface !< physical snow depth type(esmf_field), public :: soil_temp_target_grid !< 3-d soil temperature + type(esmf_field), public :: ice_temp_target_grid + !< 3-d soil temperature type(esmf_field), public :: soilm_liq_target_grid !< 3-d liquid soil moisture type(esmf_field), public :: soilm_tot_target_grid @@ -2954,6 +2956,24 @@ subroutine create_surface_esmf_fields target_ptr = init_val + print*,"- CALL FieldCreate FOR TARGET GRID sea ice column TEMPERATURE." + ice_temp_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + staggerloc=ESMF_STAGGERLOC_CENTER, & + name="ice_temp_target_grid", & + ungriddedLBound=(/1/), & + ungriddedUBound=(/lsoil_target/), rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", rc) + + print*,"- INITIALIZE TARGET grid ice temp" + call ESMF_FieldGet(ice_temp_target_grid, & + farrayPtr=target_ptr_3d, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + target_ptr_3d = init_val + print*,"- CALL FieldCreate FOR TARGET GRID SOIL TEMPERATURE." soil_temp_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 2788654a1..40d7d05d1 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1828,6 +1828,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) seaice_skin_temp_target_grid, & skin_temp_target_grid, & soil_temp_target_grid, & + ice_temp_target_grid, & soilm_liq_target_grid, & soilm_tot_target_grid, & srflag_target_grid, & @@ -1894,7 +1895,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_fice, id_tisfc, id_tprcp integer :: id_srflag, id_snwdph, id_shdmin integer :: id_shdmax, id_slope, id_snoalb - integer :: id_lai + integer :: id_lai, id_stc_ice integer :: id_stc, id_smc, id_slc integer :: id_tref, id_z_c, id_c_0 integer :: id_c_d, id_w_0, id_w_d @@ -2351,6 +2352,15 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_slc, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SLC COORD' ) + error = nf90_def_var(ncid, 'stc_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_lsoil,dim_time/), id_stc_ice) + call netcdf_err(error, 'DEFINING STC_ICE' ) + error = nf90_put_att(ncid, id_stc_ice, "long_name", "stc_ice") + call netcdf_err(error, 'DEFINING STC_ICE LONG NAME' ) + error = nf90_put_att(ncid, id_stc_ice, "units", "none") + call netcdf_err(error, 'DEFINING STC_ICE UNITS' ) + error = nf90_put_att(ncid, id_stc_ice, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING STC_ICE COORD' ) + if (convert_nst) then error = nf90_def_var(ncid, 'tref', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tref) @@ -2902,6 +2912,19 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING CANOPY MC RECORD' ) endif +! ice temperature + + print*,"- CALL FieldGather FOR TARGET GRID sea ice TEMPERATURE FOR TILE: ", tile + call ESMF_FieldGather(ice_temp_target_grid, data_one_tile_3d, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum3d(:,:,:) = data_one_tile_3d(istart:iend, jstart:jend,:) + error = nf90_put_var( ncid, id_stc_ice, dum3d, start=(/1,1,1,1/), count=(/i_target_out,j_target_out,lsoil_target,1/)) + call netcdf_err(error, 'WRITING sea ice TEMP RECORD' ) + endif + ! soil temperature print*,"- CALL FieldGather FOR TARGET GRID SOIL TEMPERATURE FOR TILE: ", tile From de67f957655ae83a710b8dabb81f9fdda9a0361c Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 1 Mar 2022 21:56:21 +0000 Subject: [PATCH 003/107] Place sea ice column temperatures in the new target ice temperature field. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 25a082933..23f6ed02f 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -848,7 +848,7 @@ subroutine interp(localpet) print*,"- CALL FieldRegridStore for 3d seaice fields." call ESMF_FieldRegridStore(soil_temp_input_grid, & - soil_temp_target_grid, & + ice_temp_target_grid, & srcmaskvalues=(/0/), & dstmaskvalues=(/0/), & polemethod=ESMF_POLEMETHOD_NONE, & @@ -869,7 +869,7 @@ subroutine interp(localpet) call error_handler("IN FieldBundleCreate", rc) call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_target_grid, & snow_liq_equiv_target_grid, seaice_skin_temp_target_grid, & - soil_temp_target_grid/), rc=rc) + ice_temp_target_grid/), rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) call ESMF_FieldBundleAdd(bundle_seaice_input, (/seaice_depth_input_grid, snow_depth_input_grid, & From d6765ca59c6c990c5cad780d2c63fd1f0ea990d7 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 8 Mar 2022 20:33:13 +0000 Subject: [PATCH 004/107] Output roughness length at land, ice and water. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 49 ++++++++++++++++++++++++++++-- sorc/chgres_cube.fd/write_data.F90 | 45 ++++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 4 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 23f6ed02f..0d739b7aa 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -60,7 +60,7 @@ module surface type(esmf_field), public :: soil_temp_target_grid !< 3-d soil temperature type(esmf_field), public :: ice_temp_target_grid - !< 3-d soil temperature + !< 3-d sea ice column temperature type(esmf_field), public :: soilm_liq_target_grid !< 3-d liquid soil moisture type(esmf_field), public :: soilm_tot_target_grid @@ -73,6 +73,10 @@ module surface !< friction velocity type(esmf_field), public :: z0_target_grid !< roughness length + type(esmf_field), public :: z0_ice_target_grid + !< roughness length at sea ice + type(esmf_field), public :: z0_water_target_grid + !< roughness length at open water type(esmf_field), public :: lai_target_grid !< leaf area index @@ -959,7 +963,7 @@ subroutine interp(localpet) bundle_water_input = ESMF_FieldBundleCreate(name="water input", rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleCreate", rc) - call ESMF_FieldBundleAdd(bundle_water_target, (/skin_temp_target_grid, z0_target_grid/), rc=rc) + call ESMF_FieldBundleAdd(bundle_water_target, (/skin_temp_target_grid, z0_water_target_grid/), rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) call ESMF_FieldBundleAdd(bundle_water_input, (/skin_temp_input_grid, z0_input_grid/), rc=rc) @@ -2197,6 +2201,7 @@ subroutine roughness real :: z0_igbp(20) real(esmf_kind_r8), pointer :: data_ptr(:,:) + real(esmf_kind_r8), pointer :: data_ptr2(:,:) real(esmf_kind_r8), pointer :: veg_type_ptr(:,:) data z0_igbp /1.089, 2.653, 0.854, 0.826, 0.800, 0.050, & @@ -2224,10 +2229,16 @@ subroutine roughness if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) + print*,"- CALL FieldGet FOR TARGET GRID Z0 ICE." + call ESMF_FieldGet(z0_ice_target_grid, & + farrayPtr=data_ptr2, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 2) then - data_ptr(i,j) = 1.0 + data_ptr2(i,j) = 1.0 elseif (landmask_ptr(i,j) == 1) then data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0 endif @@ -2924,6 +2935,38 @@ subroutine create_surface_esmf_fields target_ptr = init_val + print*,"- CALL FieldCreate FOR TARGET GRID Z0_ICE." + z0_ice_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + name="z0_ice_target_grid", & + staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", rc) + + print*,"- INITIALIZE TARGET grid z0_ice." + call ESMF_FieldGet(z0_ice_target_grid, & + farrayPtr=target_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + target_ptr = init_val + + print*,"- CALL FieldCreate FOR TARGET GRID Z0_WATER." + z0_water_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + name="z0_water_target_grid", & + staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", rc) + + print*,"- INITIALIZE TARGET grid z0_water." + call ESMF_FieldGet(z0_water_target_grid, & + farrayPtr=target_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + target_ptr = init_val + print*,"- CALL FieldCreate FOR INTERPOLATED TARGET GRID TERRAIN." terrain_from_input_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 40d7d05d1..9f1d75f4e 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1838,6 +1838,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) tprcp_target_grid, & ustar_target_grid, & z0_target_grid, & + z0_ice_target_grid, & + z0_water_target_grid, & lai_target_grid, & c_d_target_grid, & c_0_target_grid, & @@ -1886,7 +1888,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_slmsk, id_time integer :: id_lat, id_lon integer :: id_tsea, id_sheleg, id_tg3 - integer :: id_zorl, id_alvsf, id_alvwf + integer :: id_zorl, id_zorl_ice, id_alvsf, id_alvwf + integer :: id_zorl_water integer :: id_alnsf, id_alnwf, id_vfrac integer :: id_canopy, id_f10m, id_t2m integer :: id_q2m, id_vtype, id_stype @@ -2080,6 +2083,24 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_zorl, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ZORL COORD' ) + error = nf90_def_var(ncid, 'zorl_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_ice) + call netcdf_err(error, 'DEFINING ZORL_ICE' ) + error = nf90_put_att(ncid, id_zorl_ice, "long_name", "zorl_ice") + call netcdf_err(error, 'DEFINING ZORL_ICE LONG NAME' ) + error = nf90_put_att(ncid, id_zorl_ice, "units", "none") + call netcdf_err(error, 'DEFINING ZORL_ICE UNITS' ) + error = nf90_put_att(ncid, id_zorl_ice, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING ZORL_ICE COORD' ) + + error = nf90_def_var(ncid, 'zorl_water', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_water) + call netcdf_err(error, 'DEFINING ZORL_WATER' ) + error = nf90_put_att(ncid, id_zorl_water, "long_name", "zorl_water") + call netcdf_err(error, 'DEFINING ZORL_WATER LONG NAME' ) + error = nf90_put_att(ncid, id_zorl_water, "units", "none") + call netcdf_err(error, 'DEFINING ZORL_WATER UNITS' ) + error = nf90_put_att(ncid, id_zorl_water, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING ZORL_WATER COORD' ) + error = nf90_def_var(ncid, 'alvsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvsf) call netcdf_err(error, 'DEFINING ALVSF' ) error = nf90_put_att(ncid, id_alvsf, "long_name", "alvsf") @@ -2610,6 +2631,28 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING Z0 RECORD' ) endif + print*,"- CALL FieldGather FOR TARGET GRID Z0_ICE FOR TILE: ", tile + call ESMF_FieldGather(z0_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_zorl_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING Z0_ICE RECORD' ) + endif + + print*,"- CALL FieldGather FOR TARGET GRID Z0_WATER FOR TILE: ", tile + call ESMF_FieldGather(z0_water_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_zorl_water, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING Z0_WATER RECORD' ) + endif + print*,"- CALL FieldGather FOR TARGET GRID MAX SNOW ALBEDO FOR TILE: ", tile call ESMF_FieldGather(mxsno_albedo_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & From 817286fc0c71c8bf53e6d05f0c067014eb9f5692 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 9 Mar 2022 14:39:34 +0000 Subject: [PATCH 005/107] Add variable for snow-free albedo at non-land points. Fixes #123 --- sorc/chgres_cube.fd/surface.F90 | 122 ++++++++++++++++++++++++++++- sorc/chgres_cube.fd/write_data.F90 | 89 ++++++++++++++++++++- 2 files changed, 208 insertions(+), 3 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 0d739b7aa..9a83b72ee 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -33,6 +33,14 @@ module surface !< are applied at these points. ! surface fields (not including nst) + type(esmf_field), public :: alvsf_nl_target_grid + !< alvsf at non-land + type(esmf_field), public :: alvwf_nl_target_grid + !< alvwf at non-land + type(esmf_field), public :: alnsf_nl_target_grid + !< alnsf at non-land + type(esmf_field), public :: alnwf_nl_target_grid + !< alnwf at non-land type(esmf_field), public :: canopy_mc_target_grid !< canopy moisture content type(esmf_field), public :: f10m_target_grid @@ -2335,6 +2343,18 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + enddo + enddo + + print*,"- SET TARGET GRID ALVSF_NL AT NON-LAND." + call ESMF_FieldGet(alvsf_nl_target_grid, & + farrayPtr=data_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value @@ -2347,6 +2367,18 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + enddo + enddo + + print*,"- SET TARGET GRID ALVWF_NL AT NON-LAND." + call ESMF_FieldGet(alvwf_nl_target_grid, & + farrayPtr=data_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value @@ -2359,6 +2391,18 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + enddo + enddo + + print*,"- SET TARGET GRID ALNSF_NL AT NON-LAND." + call ESMF_FieldGet(alnsf_nl_target_grid, & + farrayPtr=data_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value @@ -2373,7 +2417,19 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + enddo + enddo + + print*,"- SET TARGET GRID ALNWF_NL AT NON-LAND." + call ESMF_FieldGet(alnwf_nl_target_grid, & + farrayPtr=data_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value enddo enddo @@ -2887,6 +2943,70 @@ subroutine create_surface_esmf_fields target_ptr = init_val + print*,"- CALL FieldCreate FOR TARGET ALVSF AT NON-LAND." + alvsf_nl_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + name="alvsf_nl_target_grid", & + staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", rc) + + print*,"- INITIALIZE TARGET ALVSF AT NON-LAND." + call ESMF_FieldGet(alvsf_nl_target_grid, & + farrayPtr=target_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + target_ptr = init_val + + print*,"- CALL FieldCreate FOR TARGET ALVWF AT NON-LAND." + alvwf_nl_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + name="alvwf_nl_target_grid", & + staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", rc) + + print*,"- INITIALIZE TARGET ALVWF AT NON-LAND." + call ESMF_FieldGet(alvwf_nl_target_grid, & + farrayPtr=target_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + target_ptr = init_val + + print*,"- CALL FieldCreate FOR TARGET ALNSF AT NON-LAND." + alnsf_nl_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + name="alnsf_nl_target_grid", & + staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", rc) + + print*,"- INITIALIZE TARGET ALNSF AT NON-LAND." + call ESMF_FieldGet(alnsf_nl_target_grid, & + farrayPtr=target_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + target_ptr = init_val + + print*,"- CALL FieldCreate FOR TARGET ALNWF AT NON-LAND." + alnwf_nl_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + name="alnwf_nl_target_grid", & + staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", rc) + + print*,"- INITIALIZE TARGET ALNWF AT NON-LAND." + call ESMF_FieldGet(alnwf_nl_target_grid, & + farrayPtr=target_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + target_ptr = init_val + print*,"- CALL FieldCreate FOR TARGET GRID CANOPY MOISTURE CONTENT." canopy_mc_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 9f1d75f4e..697547ed7 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1858,7 +1858,11 @@ subroutine write_fv3_sfc_data_netcdf(localpet) xtts_target_grid, & xzts_target_grid, & z_c_target_grid, & - zm_target_grid + zm_target_grid, & + alvsf_nl_target_grid, & + alvwf_nl_target_grid, & + alnsf_nl_target_grid, & + alnwf_nl_target_grid use static_data, only : alvsf_target_grid, & alnsf_target_grid, & @@ -1889,7 +1893,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_lat, id_lon integer :: id_tsea, id_sheleg, id_tg3 integer :: id_zorl, id_zorl_ice, id_alvsf, id_alvwf - integer :: id_zorl_water + integer :: id_zorl_water, id_alvsf_nl + integer :: id_alvwf_nl, id_alnsf_nl, id_alnwf_nl integer :: id_alnsf, id_alnwf, id_vfrac integer :: id_canopy, id_f10m, id_t2m integer :: id_q2m, id_vtype, id_stype @@ -2110,6 +2115,15 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alvsf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALVSF COORD' ) + error = nf90_def_var(ncid, 'alvsf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvsf_nl) + call netcdf_err(error, 'DEFINING ALVSF_NL' ) + error = nf90_put_att(ncid, id_alvsf_nl, "long_name", "alvsf_nl") + call netcdf_err(error, 'DEFINING ALVSF_NL LONG NAME' ) + error = nf90_put_att(ncid, id_alvsf_nl, "units", "none") + call netcdf_err(error, 'DEFINING ALVSF_NL UNITS' ) + error = nf90_put_att(ncid, id_alvsf_nl, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING ALVSF_NL COORD' ) + error = nf90_def_var(ncid, 'alvwf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvwf) call netcdf_err(error, 'DEFINING ALVWF' ) error = nf90_put_att(ncid, id_alvwf, "long_name", "alvwf") @@ -2119,6 +2133,15 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alvwf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALVWF COORD' ) + error = nf90_def_var(ncid, 'alvwf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvwf_nl) + call netcdf_err(error, 'DEFINING ALVWF_NL' ) + error = nf90_put_att(ncid, id_alvwf_nl, "long_name", "alvwf_nl") + call netcdf_err(error, 'DEFINING ALVWF_NL LONG NAME' ) + error = nf90_put_att(ncid, id_alvwf_nl, "units", "none") + call netcdf_err(error, 'DEFINING ALVWF_NL UNITS' ) + error = nf90_put_att(ncid, id_alvwf_nl, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING ALVWF_NL COORD' ) + error = nf90_def_var(ncid, 'alnsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnsf) call netcdf_err(error, 'DEFINING ALNSF' ) error = nf90_put_att(ncid, id_alnsf, "long_name", "alnsf") @@ -2128,6 +2151,15 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alnsf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALNSF COORD' ) + error = nf90_def_var(ncid, 'alnsf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnsf_nl) + call netcdf_err(error, 'DEFINING ALNSF_NL' ) + error = nf90_put_att(ncid, id_alnsf_nl, "long_name", "alnsf_nl") + call netcdf_err(error, 'DEFINING ALNSF_NL LONG NAME' ) + error = nf90_put_att(ncid, id_alnsf_nl, "units", "none") + call netcdf_err(error, 'DEFINING ALNSF_NL UNITS' ) + error = nf90_put_att(ncid, id_alnsf_nl, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING ALNSF_NL COORD' ) + error = nf90_def_var(ncid, 'alnwf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnwf) call netcdf_err(error, 'DEFINING ALNWF' ) error = nf90_put_att(ncid, id_alnwf, "long_name", "alnwf") @@ -2137,6 +2169,15 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alnwf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALNWF COORD' ) + error = nf90_def_var(ncid, 'alnwf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnwf_nl) + call netcdf_err(error, 'DEFINING ALNWF_NL' ) + error = nf90_put_att(ncid, id_alnwf_nl, "long_name", "alnwf_nl") + call netcdf_err(error, 'DEFINING ALNWF_NL LONG NAME' ) + error = nf90_put_att(ncid, id_alnwf_nl, "units", "none") + call netcdf_err(error, 'DEFINING ALNWF_NL UNITS' ) + error = nf90_put_att(ncid, id_alnwf_nl, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING ALNWF_NL COORD' ) + error = nf90_def_var(ncid, 'facsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_facsf) call netcdf_err(error, 'DEFINING FACSF' ) error = nf90_put_att(ncid, id_facsf, "long_name", "facsf") @@ -2754,6 +2795,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALNSF RECORD' ) endif + print*,"- CALL FieldGather FOR TARGET GRID ALNSF_NL FOR TILE: ", tile + call ESMF_FieldGather(alnsf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_alnsf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING ALNSF_NL RECORD' ) + endif + print*,"- CALL FieldGather FOR TARGET GRID ALNWF FOR TILE: ", tile call ESMF_FieldGather(alnwf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2765,6 +2817,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALNWF RECORD' ) endif + print*,"- CALL FieldGather FOR TARGET GRID ALNWF_NL FOR TILE: ", tile + call ESMF_FieldGather(alnwf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_alnwf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING ALNWF_NL RECORD' ) + endif + print*,"- CALL FieldGather FOR TARGET GRID ALVSF FOR TILE: ", tile call ESMF_FieldGather(alvsf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2776,6 +2839,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALVSF RECORD' ) endif + print*,"- CALL FieldGather FOR TARGET GRID ALVSF_NL FOR TILE: ", tile + call ESMF_FieldGather(alvsf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_alvsf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING ALVSF_NL RECORD' ) + endif + print*,"- CALL FieldGather FOR TARGET GRID ALVWF FOR TILE: ", tile call ESMF_FieldGather(alvwf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2787,6 +2861,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALVWF RECORD' ) endif + print*,"- CALL FieldGather FOR TARGET GRID ALVWF_NL FOR TILE: ", tile + call ESMF_FieldGather(alvwf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_alvwf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING ALVWF_NL RECORD' ) + endif + print*,"- CALL FieldGather FOR TARGET GRID MAX VEGETATION GREENNESS FOR TILE: ", tile call ESMF_FieldGather(max_veg_greenness_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & From 84450d132e91834d7f183b193a99f3cfa5adba36 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 9 Mar 2022 16:02:31 +0000 Subject: [PATCH 006/107] Add snow fields for sea ice points. Fixes #123 --- sorc/chgres_cube.fd/surface.F90 | 40 ++++++++++++++++++++++++-- sorc/chgres_cube.fd/write_data.F90 | 46 ++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 9a83b72ee..ca4ae9ead 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -65,6 +65,10 @@ module surface !< liquid equiv snow depth type(esmf_field), public :: snow_depth_target_grid !< physical snow depth + type(esmf_field), public :: snow_liq_equiv_at_ice_target_grid + !< liquid equiv snow depth at sea ice + type(esmf_field), public :: snow_depth_at_ice_target_grid + !< physical snow depth at sea ice type(esmf_field), public :: soil_temp_target_grid !< 3-d soil temperature type(esmf_field), public :: ice_temp_target_grid @@ -879,8 +883,8 @@ subroutine interp(localpet) bundle_seaice_input = ESMF_FieldBundleCreate(name="sea ice input", rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleCreate", rc) - call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_target_grid, & - snow_liq_equiv_target_grid, seaice_skin_temp_target_grid, & + call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_at_ice_target_grid, & + snow_liq_equiv_at_ice_target_grid, seaice_skin_temp_target_grid, & ice_temp_target_grid/), rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) @@ -2847,6 +2851,22 @@ subroutine create_surface_esmf_fields target_ptr = init_val + print*,"- CALL FieldCreate FOR TARGET GRID SNOW LIQ EQUIV AT SEA ICE." + snow_liq_equiv_at_ice_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + name="snow_liq_equiv_at_ice_target_grid", & + staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", rc) + + print*,"- INITIALIZE TARGET grid snow liq equiv at sea ice." + call ESMF_FieldGet(snow_liq_equiv_at_ice_target_grid, & + farrayPtr=target_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + target_ptr = init_val + print*,"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH." snow_depth_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -2863,6 +2883,22 @@ subroutine create_surface_esmf_fields target_ptr = init_val + print*,"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH AT SEA ICE." + snow_depth_at_ice_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + name="snow_depth_at_ice_target_grid", & + staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", rc) + + print*,"- INITIALIZE TARGET grid snow depth at sea ice." + call ESMF_FieldGet(snow_depth_at_ice_target_grid, & + farrayPtr=target_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + target_ptr = init_val + print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE FRACTION." seaice_fract_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 697547ed7..96d2dbe02 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1834,6 +1834,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) srflag_target_grid, & snow_liq_equiv_target_grid, & snow_depth_target_grid, & + snow_liq_equiv_at_ice_target_grid, & + snow_depth_at_ice_target_grid, & t2m_target_grid, & tprcp_target_grid, & ustar_target_grid, & @@ -1891,7 +1893,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_x, id_y, id_lsoil integer :: id_slmsk, id_time integer :: id_lat, id_lon - integer :: id_tsea, id_sheleg, id_tg3 + integer :: id_tsea, id_sheleg, id_sheleg_ice, id_tg3 integer :: id_zorl, id_zorl_ice, id_alvsf, id_alvwf integer :: id_zorl_water, id_alvsf_nl integer :: id_alvwf_nl, id_alnsf_nl, id_alnwf_nl @@ -1901,7 +1903,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_facsf, id_facwf, id_uustar integer :: id_ffmm, id_ffhh, id_hice integer :: id_fice, id_tisfc, id_tprcp - integer :: id_srflag, id_snwdph, id_shdmin + integer :: id_srflag, id_snwdph, id_snwdph_ice, id_shdmin integer :: id_shdmax, id_slope, id_snoalb integer :: id_lai, id_stc_ice integer :: id_stc, id_smc, id_slc @@ -2070,6 +2072,15 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_sheleg, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SHELEG COORD' ) + error = nf90_def_var(ncid, 'sheleg_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_ice) + call netcdf_err(error, 'DEFINING SHELEG AT ICE' ) + error = nf90_put_att(ncid, id_sheleg_ice, "long_name", "sheleg_ice") + call netcdf_err(error, 'DEFINING SHELEG ICE LONG NAME' ) + error = nf90_put_att(ncid, id_sheleg_ice, "units", "none") + call netcdf_err(error, 'DEFINING SHELEG AT ICE UNITS' ) + error = nf90_put_att(ncid, id_sheleg_ice, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING SHELEG AT ICE COORD' ) + error = nf90_def_var(ncid, 'tg3', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3) call netcdf_err(error, 'DEFINING TG3' ) error = nf90_put_att(ncid, id_tg3, "long_name", "tg3") @@ -2340,6 +2351,15 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_snwdph, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SNWDPH COORD' ) + error = nf90_def_var(ncid, 'snwdph_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph_ice) + call netcdf_err(error, 'DEFINING SNWDPH AT ICE' ) + error = nf90_put_att(ncid, id_snwdph_ice, "long_name", "snwdph_ice") + call netcdf_err(error, 'DEFINING SNWDPH AT ICE LONG NAME' ) + error = nf90_put_att(ncid, id_snwdph_ice, "units", "none") + call netcdf_err(error, 'DEFINING SNWDPH AT ICE UNITS' ) + error = nf90_put_att(ncid, id_snwdph_ice, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING SNWDPH AT ICE COORD' ) + error = nf90_def_var(ncid, 'shdmin', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_shdmin) call netcdf_err(error, 'DEFINING SHDMIN' ) error = nf90_put_att(ncid, id_shdmin, "long_name", "shdmin") @@ -2639,6 +2659,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SNOW LIQ EQUIV RECORD' ) endif + print*,"- CALL FieldGather FOR TARGET GRID SNOW LIQ EQUIV at ice FOR TILE: ", tile + call ESMF_FieldGather(snow_liq_equiv_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_sheleg_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING SNOW LIQ EQUIV at ice RECORD' ) + endif + print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH FOR TILE: ", tile call ESMF_FieldGather(snow_depth_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2650,6 +2681,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SNWDPH RECORD' ) endif + print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH at ice FOR TILE: ", tile + call ESMF_FieldGather(snow_depth_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_snwdph_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING SNWDPH at ice RECORD' ) + endif + print*,"- CALL FieldGather FOR TARGET GRID SLOPE TYPE FOR TILE: ", tile call ESMF_FieldGather(slope_type_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & From b7bdc867376ea22c2d5305ba73851eef7271d5e6 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 9 Mar 2022 21:32:49 +0000 Subject: [PATCH 007/107] Output separate records for land skin temperature and sst. Fixes #123 --- sorc/chgres_cube.fd/surface.F90 | 28 +++++++++++++++++++++++----- sorc/chgres_cube.fd/write_data.F90 | 23 ++++++++++++++++++++++- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index ca4ae9ead..744657b8e 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -59,6 +59,8 @@ module surface !< sea ice skin temperature type(esmf_field), public :: skin_temp_target_grid !< skin temperature/sst + type(esmf_field), public :: sst_target_grid + !< sst at open water type(esmf_field), public :: srflag_target_grid !< snow/rain flag type(esmf_field), public :: snow_liq_equiv_target_grid @@ -956,7 +958,7 @@ subroutine interp(localpet) print*,"- CALL FieldRegridStore for water fields." call ESMF_FieldRegridStore(skin_temp_input_grid, & - skin_temp_target_grid, & + sst_target_grid, & srcmaskvalues=(/0/), & dstmaskvalues=(/0/), & polemethod=ESMF_POLEMETHOD_NONE, & @@ -975,7 +977,7 @@ subroutine interp(localpet) bundle_water_input = ESMF_FieldBundleCreate(name="water input", rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleCreate", rc) - call ESMF_FieldBundleAdd(bundle_water_target, (/skin_temp_target_grid, z0_water_target_grid/), rc=rc) + call ESMF_FieldBundleAdd(bundle_water_target, (/sst_target_grid, z0_water_target_grid/), rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) call ESMF_FieldBundleAdd(bundle_water_input, (/skin_temp_input_grid, z0_input_grid/), rc=rc) @@ -2548,10 +2550,10 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) > 0.0) then - skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + & - ( (1.0 - fice_ptr(i,j)) * frz_ice ) +! skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + & +! ( (1.0 - fice_ptr(i,j)) * frz_ice ) else - seaice_skint_ptr(i,j) = skint_ptr(i,j) +! seaice_skint_ptr(i,j) = skint_ptr(i,j) hice_ptr(i,j) = 0.0 endif enddo @@ -2931,6 +2933,22 @@ subroutine create_surface_esmf_fields target_ptr = init_val + print*,"- CALL FieldCreate FOR TARGET GRID sst." + sst_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + name="sst_target_grid", & + staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", rc) + + print*,"- INITIALIZE TARGET sst." + call ESMF_FieldGet(sst_target_grid, & + farrayPtr=target_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + target_ptr = init_val + print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE SKIN TEMP." seaice_skin_temp_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 96d2dbe02..b840e4940 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1827,6 +1827,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) seaice_fract_target_grid, & seaice_skin_temp_target_grid, & skin_temp_target_grid, & + sst_target_grid, & soil_temp_target_grid, & ice_temp_target_grid, & soilm_liq_target_grid, & @@ -1893,7 +1894,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_x, id_y, id_lsoil integer :: id_slmsk, id_time integer :: id_lat, id_lon - integer :: id_tsea, id_sheleg, id_sheleg_ice, id_tg3 + integer :: id_tsfcl, id_tsea, id_sheleg, id_sheleg_ice, id_tg3 integer :: id_zorl, id_zorl_ice, id_alvsf, id_alvwf integer :: id_zorl_water, id_alvsf_nl integer :: id_alvwf_nl, id_alnsf_nl, id_alnwf_nl @@ -2054,6 +2055,15 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_slmsk, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SLMSK COORD' ) + error = nf90_def_var(ncid, 'tsfcl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tsfcl) + call netcdf_err(error, 'DEFINING TSFCL' ) + error = nf90_put_att(ncid, id_tsfcl, "long_name", "tsfcl") + call netcdf_err(error, 'DEFINING TSFCL LONG NAME' ) + error = nf90_put_att(ncid, id_tsfcl, "units", "none") + call netcdf_err(error, 'DEFINING TSFCL UNITS' ) + error = nf90_put_att(ncid, id_tsfcl, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING TSFCL COORD' ) + error = nf90_def_var(ncid, 'tsea', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tsea) call netcdf_err(error, 'DEFINING TSEA' ) error = nf90_put_att(ncid, id_tsea, "long_name", "tsea") @@ -3054,6 +3064,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", error) + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_tsfcl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING TSFCL RECORD' ) + endif + + print*,"- CALL FieldGather FOR TARGET GRID sst FOR TILE: ", tile + call ESMF_FieldGather(sst_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + if (localpet == 0) then dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) error = nf90_put_var( ncid, id_tsea, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) From 9b120bdf065a285e9996cd09c4239c77e1a2b50c Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 9 Mar 2022 21:55:30 +0000 Subject: [PATCH 008/107] Rename roughness length records. Fixes #123 --- sorc/chgres_cube.fd/write_data.F90 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index b840e4940..5b977b0af 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -2100,14 +2100,14 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_tg3, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TG3 COORD' ) - error = nf90_def_var(ncid, 'zorl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl) - call netcdf_err(error, 'DEFINING ZORL' ) - error = nf90_put_att(ncid, id_zorl, "long_name", "zorl") - call netcdf_err(error, 'DEFINING ZORL LONG NAME' ) + error = nf90_def_var(ncid, 'zorll', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl) + call netcdf_err(error, 'DEFINING ZORLL' ) + error = nf90_put_att(ncid, id_zorl, "long_name", "zorll") + call netcdf_err(error, 'DEFINING ZORLL LONG NAME' ) error = nf90_put_att(ncid, id_zorl, "units", "none") - call netcdf_err(error, 'DEFINING ZORL UNITS' ) + call netcdf_err(error, 'DEFINING ZORLL UNITS' ) error = nf90_put_att(ncid, id_zorl, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING ZORL COORD' ) + call netcdf_err(error, 'DEFINING ZORLL COORD' ) error = nf90_def_var(ncid, 'zorl_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_ice) call netcdf_err(error, 'DEFINING ZORL_ICE' ) @@ -2118,14 +2118,14 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_zorl_ice, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ZORL_ICE COORD' ) - error = nf90_def_var(ncid, 'zorl_water', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_water) - call netcdf_err(error, 'DEFINING ZORL_WATER' ) - error = nf90_put_att(ncid, id_zorl_water, "long_name", "zorl_water") - call netcdf_err(error, 'DEFINING ZORL_WATER LONG NAME' ) + error = nf90_def_var(ncid, 'zorl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_water) + call netcdf_err(error, 'DEFINING ZORL' ) + error = nf90_put_att(ncid, id_zorl_water, "long_name", "zorl") + call netcdf_err(error, 'DEFINING ZORL LONG NAME' ) error = nf90_put_att(ncid, id_zorl_water, "units", "none") - call netcdf_err(error, 'DEFINING ZORL_WATER UNITS' ) + call netcdf_err(error, 'DEFINING ZORL UNITS' ) error = nf90_put_att(ncid, id_zorl_water, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING ZORL_WATER COORD' ) + call netcdf_err(error, 'DEFINING ZORL COORD' ) error = nf90_def_var(ncid, 'alvsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvsf) call netcdf_err(error, 'DEFINING ALVSF' ) From c3c6e3ae31b90c1ffaae9f1be875e05b791ba150 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 14 Mar 2022 14:19:56 +0000 Subject: [PATCH 009/107] Add logical - fract_grid - to turn on or off the fractional grid option. Fixes #123. --- sorc/chgres_cube.fd/model_grid.F90 | 17 ++++--- sorc/chgres_cube.fd/program_setup.F90 | 3 ++ sorc/chgres_cube.fd/surface.F90 | 72 ++++++++++++++++++++++++++- 3 files changed, 84 insertions(+), 8 deletions(-) diff --git a/sorc/chgres_cube.fd/model_grid.F90 b/sorc/chgres_cube.fd/model_grid.F90 index ac8bf9ad3..e8b6cd8ea 100644 --- a/sorc/chgres_cube.fd/model_grid.F90 +++ b/sorc/chgres_cube.fd/model_grid.F90 @@ -1110,7 +1110,7 @@ subroutine define_target_grid(localpet, npets) use program_setup, only : mosaic_file_target_grid, & orog_dir_target_grid, & orog_files_target_grid, & - nsoill_out + nsoill_out, fract_grid implicit none @@ -1329,13 +1329,16 @@ subroutine define_target_grid(localpet, npets) call get_model_mask_terrain(trim(the_file), i_target, j_target, landmask_one_tile, & terrain_one_tile, land_frac_one_tile) -! seamask_one_tile = 0 ! all land -! where(floor(land_frac_one_tile) == 0) seamask_one_tile = 1 ! at least some water -! landmask_one_tile = 0 ! all water -! where(ceiling(land_frac_one_tile) == 1) landmask_one_tile = 1 ! at least some land + if (fract_grid) then +! seamask_one_tile = 0 ! all land +! where(floor(land_frac_one_tile) == 0) seamask_one_tile = 1 ! at least some water +! landmask_one_tile = 0 ! all water +! where(ceiling(land_frac_one_tile) == 1) landmask_one_tile = 1 ! at least some land + else + seamask_one_tile = 0 ! all land + where(landmask_one_tile == 0) seamask_one_tile=1 + endif - seamask_one_tile = 0 ! all land - where(landmask_one_tile == 0) seamask_one_tile=1 call get_model_latlons(mosaic_file_target_grid, orog_dir_target_grid, num_tiles_target_grid, tile, & i_target, j_target, ip1_target, jp1_target, latitude_one_tile, & latitude_s_one_tile, latitude_w_one_tile, longitude_one_tile, & diff --git a/sorc/chgres_cube.fd/program_setup.F90 b/sorc/chgres_cube.fd/program_setup.F90 index 5e854a2c3..c594a85ef 100644 --- a/sorc/chgres_cube.fd/program_setup.F90 +++ b/sorc/chgres_cube.fd/program_setup.F90 @@ -97,6 +97,9 @@ module program_setup logical, public :: convert_sfc = .false. !< Convert sfc data when true. logical, public :: wam_cold_start = .false. !< When true, cold start for whole atmosphere model. + + logical, public :: fract_grid = .false. + ! Options for replacing vegetation/soil type, veg fraction, and lai with data from the grib2 file ! Default is to use climatology instead logical, public :: vgtyp_from_climo = .true. !< If false, interpolate vegetation type from the input diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 744657b8e..fdc329c83 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -717,6 +717,7 @@ subroutine interp(localpet) enddo nullify(veg_type_target_ptr) endif + print*,"- CALL FieldRegridRelease." call ESMF_FieldRegridRelease(routehandle=regrid_all_land, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -730,6 +731,10 @@ subroutine interp(localpet) mask_input_ptr = 1 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 0 +!cfract +!cfract under fractional grid, seamask_target will be '1' if there is +!cfract at least some water. + mask_target_ptr = seamask_target_ptr method=ESMF_REGRIDMETHOD_CONSERVE @@ -783,6 +788,10 @@ subroutine interp(localpet) do tile = 1, num_tiles_target_grid +!cfract according to Shan, the ice fraction is not scaled for +!cfract the fraction of non-land. So if a point is 50% +!cfract land and non-land, an ice frac to 100% means the +!cfract entire non-land portion is ice covered. print*,"- CALL FieldGather FOR TARGET GRID SEAICE FRACTION TILE: ", tile call ESMF_FieldGather(seaice_fract_target_grid, data_one_tile, rootPet=0, tile=tile, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -826,6 +835,10 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldScatter", rc) +!cfrac +! under fractional grid, landmask_target_grid is '1' if there is at least some +! land and '0' if all water. Updating to points to '2' will have consequences +! later. Don't do this? print*,"- CALL FieldScatter FOR TARGET LANDMASK TILE: ", tile call ESMF_FieldScatter(landmask_target_grid, mask_target_one_tile, rootPet=0, tile=tile, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -854,6 +867,8 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract Instead, should I check if 'fice' is non-zero to set +!cfract mask_target_ptr? mask_target_ptr = 0 do j = clb_target(2), cub_target(2) do i = clb_target(1), cub_target(1) @@ -885,6 +900,8 @@ subroutine interp(localpet) bundle_seaice_input = ESMF_FieldBundleCreate(name="sea ice input", rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleCreate", rc) + +!cfract Separate snow fields at ice is not needed? call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_at_ice_target_grid, & snow_liq_equiv_at_ice_target_grid, seaice_skin_temp_target_grid, & ice_temp_target_grid/), rc=rc) @@ -923,6 +940,7 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) +!cfract using ice flag of '2' here. cant do that. if (localpet == 0) then where(mask_target_one_tile == 1) mask_target_one_tile = 0 where(mask_target_one_tile == 2) mask_target_one_tile = 1 @@ -944,12 +962,16 @@ subroutine interp(localpet) call error_handler("IN FieldRegridRelease", rc) !--------------------------------------------------------------------------------------------- -! Now interpolate water fields. +! Now interpolate open water fields. !--------------------------------------------------------------------------------------------- mask_input_ptr = 0 where (nint(landmask_input_ptr) == 0) mask_input_ptr = 1 +!cfract dont include any points with ice. +!cfract use seamask_target, which is 1 if there is some water. +!cfract then remove points where fice is > 0. +!cfract We want points with at least some water, but no ice. mask_target_ptr = 0 where (landmask_target_ptr == 0) mask_target_ptr = 1 @@ -1048,6 +1070,7 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) +!cfract - here mask must be points with some water, but no ice. if (localpet == 0) then allocate(water_target_one_tile(i_target,j_target)) water_target_one_tile = 0 @@ -1079,6 +1102,7 @@ subroutine interp(localpet) mask_input_ptr = 0 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1 +!cfract this logic should work for fractional grids. mask_target_ptr = 0 where (landmask_target_ptr == 1) mask_target_ptr = 1 @@ -1139,6 +1163,7 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) +!cfract 0 - all water; 1 - some land. if (localpet == 0) then allocate(land_target_one_tile(i_target,j_target)) land_target_one_tile = 0 @@ -1182,6 +1207,8 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract veg_type_target should contain a valid value at points with +!cfract any land. So this logic should work with fractional grids. mask_target_ptr = 0 where (nint(veg_type_target_ptr) == veg_type_landice_target) mask_target_ptr = 1 @@ -1267,6 +1294,8 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) +!cfract setting land_target_one_tile. this should work for fractional grids. + if (localpet == 0) then land_target_one_tile = 0 where(nint(veg_type_target_one_tile) == veg_type_landice_target) land_target_one_tile = 1 @@ -1302,6 +1331,7 @@ subroutine interp(localpet) where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1 where (nint(veg_type_input_ptr) == veg_type_landice_input) mask_input_ptr = 0 +!cfract This should work for fractional grid. mask_target_ptr = 0 where (landmask_target_ptr == 1) mask_target_ptr = 1 where (nint(veg_type_target_ptr) == veg_type_landice_target) mask_target_ptr = 0 @@ -1483,6 +1513,9 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) +!cfract Here mask_target_one_tile is 'landmask_target_grid'. it is +!cfract then modified by veg_type_target_grid. so this should work for +!cfract grids. if (localpet == 0) then where(nint(veg_type_target_one_tile) == veg_type_landice_target) mask_target_one_tile = 0 endif @@ -1635,6 +1668,7 @@ subroutine calc_liq_soil_moisture ! Check land points that are not permanent land ice. !--------------------------------------------------------------------------------------------- +!cfract - 1 for at least some land. if (landmask_ptr(i,j) == 1 .and. nint(veg_type_ptr(i,j)) /= veg_type_landice_target) then soil_type = nint(soil_type_ptr(i,j)) @@ -1918,6 +1952,7 @@ subroutine rescale_soil_moisture ! Check land points that are not permanent land ice. !--------------------------------------------------------------------------------------------- +!cfract when '1' will contain some land. if (landmask_ptr(i,j) == 1 .and. nint(veg_type_ptr(i,j)) /= veg_type_landice_target) then soilt_target = nint(soil_type_target_ptr(i,j)) @@ -2064,6 +2099,7 @@ subroutine adjust_soilt_for_terrain do j = clb(2), cub(2) do i = clb(1), cub(1) +!cfract at least some land when equal to '1'. if (landmask_ptr(i,j) == 1) then terrain_diff = abs(terrain_input_ptr(i,j) - terrain_target_ptr(i,j)) if (terrain_diff > 100.0) then @@ -2249,6 +2285,8 @@ subroutine roughness if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract should check for fice instead? under fractional +!cfract grids need to preserve original landmask_target. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 2) then @@ -2313,6 +2351,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract Setting to flag value at water. With fractional grid, +!cfract restrict this to points that are all water. i.e., +!cfract where landmask_ptr = 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2325,6 +2366,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract Setting to flag value at water. With fractional grid, +!cfract restrict this to points that are all water. i.e., +!cfract where landmask_ptr = 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2337,6 +2381,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract Setting to flag value at water. With fractional grid, +!cfract restrict this to points that are all water. i.e., +!cfract where landmask_ptr = 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) veg_type_ptr(i,j) = 0.0 @@ -2349,6 +2396,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract This array contains albedo at points with at least +!cfract some land. At all other points set to flag value. +!cfract That means points where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value @@ -2361,6 +2411,8 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract Setting to flag value at all non-land - ice and all water. +!cfract for fractional grid, this is where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value @@ -2445,6 +2497,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract for fract grid, this is where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2457,6 +2510,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract for fract grid, this is where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2469,6 +2523,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract for fract grid, this is where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2481,6 +2536,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract for fract grid, this is where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2493,6 +2549,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract for fract grid, this is where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) veg_greenness_ptr(i,j) = 0.0 @@ -2505,6 +2562,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract for fract grid, this is where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2565,6 +2623,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract don't use the '2' flag for ice. Use fice instead? do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 2) then ! sea ice @@ -2581,6 +2640,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract this should work for fractional grids. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0) then ! open water @@ -2595,6 +2655,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract this should work for fractional grids. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0) then ! open water @@ -2615,6 +2676,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract replace check of '2' with fice? do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 2 .or. landmask_ptr(i,j) == 0 .or. & @@ -2631,6 +2693,8 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +!cfract, is skint_ptr the new sst field? need to use new +!cfract sst_target_grid here. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0) then @@ -2695,6 +2759,10 @@ subroutine nst_land_fill if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldGet", rc) +!cfract Setting filler value for tref at ice and land points. +!cfract Under fractional grids use seamask_target, where =0 +!cfract is all land. And use fice field for ice. +!cfrac where(seamask_target == 0) .and where (fice > 0) data_ptr=skint_ptr where(mask_ptr /= 0) data_ptr = skint_ptr ! xz @@ -2705,6 +2773,7 @@ subroutine nst_land_fill if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldGet", rc) +!cfract same as above. where(mask_ptr /= 0) data_ptr = xz_fill do i = 1,num_nst_fields_minus2 @@ -2717,6 +2786,7 @@ subroutine nst_land_fill if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldGet", rc) +!cfract same as above. where(mask_ptr /= 0) data_ptr = nst_fill enddo From 3f45d22f7dadd0c419fe0070fc2b5f72f82bca47 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 14 Mar 2022 17:21:47 +0000 Subject: [PATCH 010/107] Add logic to compute snow at sea ice when 'fract_grid' is true. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 23 ++++++++++++++++++++--- sorc/chgres_cube.fd/write_data.F90 | 11 ++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index fdc329c83..fbac31dea 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -386,7 +386,8 @@ subroutine interp(localpet) vgfrc_from_climo, & minmax_vgfrc_from_climo, & lai_from_climo, & - tg3_from_soil + tg3_from_soil, & + fract_grid use static_data, only : veg_type_target_grid, & soil_type_target_grid, & @@ -901,12 +902,19 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleCreate", rc) -!cfract Separate snow fields at ice is not needed? - call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_at_ice_target_grid, & + if (fract_grid) then + call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_at_ice_target_grid, & snow_liq_equiv_at_ice_target_grid, seaice_skin_temp_target_grid, & ice_temp_target_grid/), rc=rc) + else + call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_target_grid, & + snow_liq_equiv_target_grid, seaice_skin_temp_target_grid, & + ice_temp_target_grid/), rc=rc) + endif + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) + call ESMF_FieldBundleAdd(bundle_seaice_input, (/seaice_depth_input_grid, snow_depth_input_grid, & snow_liq_equiv_input_grid, seaice_skin_temp_input_grid, & soil_temp_input_grid/), rc=rc) @@ -2804,6 +2812,8 @@ subroutine create_surface_esmf_fields use model_grid, only : target_grid, lsoil_target + use program_setup, only : fract_grid + implicit none integer :: rc @@ -2923,6 +2933,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val + if (fract_grid) then print*,"- CALL FieldCreate FOR TARGET GRID SNOW LIQ EQUIV AT SEA ICE." snow_liq_equiv_at_ice_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -2939,6 +2950,8 @@ subroutine create_surface_esmf_fields target_ptr = init_val + endif ! fractional grid + print*,"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH." snow_depth_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -2955,6 +2968,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val + if (fract_grid) then print*,"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH AT SEA ICE." snow_depth_at_ice_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -2970,6 +2984,7 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr = init_val + endif print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE FRACTION." seaice_fract_target_grid = ESMF_FieldCreate(target_grid, & @@ -3787,6 +3802,8 @@ subroutine cleanup_target_sfc_data call ESMF_FieldDestroy(ustar_target_grid, rc=rc) call ESMF_FieldDestroy(snow_liq_equiv_target_grid, rc=rc) call ESMF_FieldDestroy(snow_depth_target_grid, rc=rc) + if (ESMF_FieldIsCreated(snow_liq_equiv_at_ice_target_grid)) call ESMF_FieldDestroy(snow_liq_equiv_at_ice_target_grid, rc=rc) + if (ESMF_FieldIsCreated(snow_depth_at_ice_target_grid)) call ESMF_FieldDestroy(snow_depth_at_ice_target_grid, rc=rc) call ESMF_FieldDestroy(seaice_fract_target_grid, rc=rc) call ESMF_FieldDestroy(seaice_depth_target_grid, rc=rc) call ESMF_FieldDestroy(seaice_skin_temp_target_grid, rc=rc) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 5b977b0af..893e64f0b 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1817,7 +1817,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) i_target, j_target, lsoil_target use program_setup, only : convert_nst, halo=>halo_bndy, & - regional, lai_from_climo + regional, lai_from_climo, & + fract_grid use surface, only : canopy_mc_target_grid, & f10m_target_grid, & @@ -2082,6 +2083,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_sheleg, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SHELEG COORD' ) + if(fract_grid)then error = nf90_def_var(ncid, 'sheleg_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_ice) call netcdf_err(error, 'DEFINING SHELEG AT ICE' ) error = nf90_put_att(ncid, id_sheleg_ice, "long_name", "sheleg_ice") @@ -2090,6 +2092,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING SHELEG AT ICE UNITS' ) error = nf90_put_att(ncid, id_sheleg_ice, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SHELEG AT ICE COORD' ) + endif error = nf90_def_var(ncid, 'tg3', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3) call netcdf_err(error, 'DEFINING TG3' ) @@ -2361,6 +2364,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_snwdph, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SNWDPH COORD' ) + if(fract_grid)then error = nf90_def_var(ncid, 'snwdph_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph_ice) call netcdf_err(error, 'DEFINING SNWDPH AT ICE' ) error = nf90_put_att(ncid, id_snwdph_ice, "long_name", "snwdph_ice") @@ -2369,6 +2373,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING SNWDPH AT ICE UNITS' ) error = nf90_put_att(ncid, id_snwdph_ice, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SNWDPH AT ICE COORD' ) + endif error = nf90_def_var(ncid, 'shdmin', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_shdmin) call netcdf_err(error, 'DEFINING SHDMIN' ) @@ -2669,6 +2674,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SNOW LIQ EQUIV RECORD' ) endif + if(fract_grid) then print*,"- CALL FieldGather FOR TARGET GRID SNOW LIQ EQUIV at ice FOR TILE: ", tile call ESMF_FieldGather(snow_liq_equiv_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2679,6 +2685,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_sheleg_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING SNOW LIQ EQUIV at ice RECORD' ) endif + endif print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH FOR TILE: ", tile call ESMF_FieldGather(snow_depth_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) @@ -2691,6 +2698,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SNWDPH RECORD' ) endif + if (fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH at ice FOR TILE: ", tile call ESMF_FieldGather(snow_depth_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2701,6 +2709,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_snwdph_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING SNWDPH at ice RECORD' ) endif + endif print*,"- CALL FieldGather FOR TARGET GRID SLOPE TYPE FOR TILE: ", tile call ESMF_FieldGather(slope_type_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) From a917501d98b73ad00de385194c0109d4b3df6b3b Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 14 Mar 2022 18:09:36 +0000 Subject: [PATCH 011/107] Compute separate albedo for land/non-land when 'fract_grid' is true. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 28 ++++++++++++++++++++++++---- sorc/chgres_cube.fd/write_data.F90 | 16 ++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index fbac31dea..056601542 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2312,6 +2312,8 @@ end subroutine roughness !! @author George Gayno NOAA/EMC subroutine qc_check + use program_setup, only : fract_grid + use model_grid, only : landmask_target_grid use static_data, only : alvsf_target_grid, & @@ -2409,10 +2411,12 @@ subroutine qc_check !cfract That means points where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value + if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value enddo enddo + if(fract_grid)then print*,"- SET TARGET GRID ALVSF_NL AT NON-LAND." call ESMF_FieldGet(alvsf_nl_target_grid, & farrayPtr=data_ptr, rc=rc) @@ -2426,6 +2430,7 @@ subroutine qc_check if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value enddo enddo + endif print*,"- SET TARGET GRID ALVWF AT NON-LAND." call ESMF_FieldGet(alvwf_target_grid, & @@ -2435,10 +2440,12 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value + if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value enddo enddo + if(fract_grid)then print*,"- SET TARGET GRID ALVWF_NL AT NON-LAND." call ESMF_FieldGet(alvwf_nl_target_grid, & farrayPtr=data_ptr, rc=rc) @@ -2450,6 +2457,7 @@ subroutine qc_check if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value enddo enddo + endif print*,"- SET TARGET GRID ALNSF AT NON-LAND." call ESMF_FieldGet(alnsf_target_grid, & @@ -2459,10 +2467,12 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value + if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value enddo enddo + if(fract_grid)then print*,"- SET TARGET GRID ALNSF_NL AT NON-LAND." call ESMF_FieldGet(alnsf_nl_target_grid, & farrayPtr=data_ptr, rc=rc) @@ -2474,6 +2484,7 @@ subroutine qc_check if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value enddo enddo + endif print*,"- SET TARGET GRID ALNWF AT NON-LAND." call ESMF_FieldGet(alnwf_target_grid, & @@ -2483,10 +2494,12 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value + if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value enddo enddo + if(fract_grid)then print*,"- SET TARGET GRID ALNWF_NL AT NON-LAND." call ESMF_FieldGet(alnwf_nl_target_grid, & farrayPtr=data_ptr, rc=rc) @@ -2498,6 +2511,7 @@ subroutine qc_check if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value enddo enddo + endif print*,"- SET NON-LAND FLAG FOR TARGET GRID FACSF." call ESMF_FieldGet(facsf_target_grid, & @@ -3082,6 +3096,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val + if(fract_grid)then print*,"- CALL FieldCreate FOR TARGET ALVSF AT NON-LAND." alvsf_nl_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3145,6 +3160,7 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr = init_val + endif ! fract_grid print*,"- CALL FieldCreate FOR TARGET GRID CANOPY MOISTURE CONTENT." canopy_mc_target_grid = ESMF_FieldCreate(target_grid, & @@ -3818,6 +3834,10 @@ subroutine cleanup_target_sfc_data call ESMF_FieldDestroy(soil_temp_target_grid, rc=rc) call ESMF_FieldDestroy(soilm_tot_target_grid, rc=rc) call ESMF_FieldDestroy(soilm_liq_target_grid, rc=rc) + if (ESMF_FieldIsCreated(alvsf_nl_target_grid)) call ESMF_FieldDestroy(alvsf_nl_target_grid, rc=rc) + if (ESMF_FieldIsCreated(alvwf_nl_target_grid)) call ESMF_FieldDestroy(alvwf_nl_target_grid, rc=rc) + if (ESMF_FieldIsCreated(alnsf_nl_target_grid)) call ESMF_FieldDestroy(alnsf_nl_target_grid, rc=rc) + if (ESMF_FieldIsCreated(alnwf_nl_target_grid)) call ESMF_FieldDestroy(alnwf_nl_target_grid, rc=rc) end subroutine cleanup_target_sfc_data diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 893e64f0b..2fdfdba31 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -2139,6 +2139,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alvsf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALVSF COORD' ) + if(fract_grid)then error = nf90_def_var(ncid, 'alvsf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvsf_nl) call netcdf_err(error, 'DEFINING ALVSF_NL' ) error = nf90_put_att(ncid, id_alvsf_nl, "long_name", "alvsf_nl") @@ -2147,6 +2148,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ALVSF_NL UNITS' ) error = nf90_put_att(ncid, id_alvsf_nl, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALVSF_NL COORD' ) + endif error = nf90_def_var(ncid, 'alvwf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvwf) call netcdf_err(error, 'DEFINING ALVWF' ) @@ -2157,6 +2159,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alvwf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALVWF COORD' ) + if(fract_grid)then error = nf90_def_var(ncid, 'alvwf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvwf_nl) call netcdf_err(error, 'DEFINING ALVWF_NL' ) error = nf90_put_att(ncid, id_alvwf_nl, "long_name", "alvwf_nl") @@ -2165,6 +2168,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ALVWF_NL UNITS' ) error = nf90_put_att(ncid, id_alvwf_nl, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALVWF_NL COORD' ) + endif error = nf90_def_var(ncid, 'alnsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnsf) call netcdf_err(error, 'DEFINING ALNSF' ) @@ -2175,6 +2179,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alnsf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALNSF COORD' ) + if(fract_grid)then error = nf90_def_var(ncid, 'alnsf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnsf_nl) call netcdf_err(error, 'DEFINING ALNSF_NL' ) error = nf90_put_att(ncid, id_alnsf_nl, "long_name", "alnsf_nl") @@ -2183,6 +2188,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ALNSF_NL UNITS' ) error = nf90_put_att(ncid, id_alnsf_nl, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALNSF_NL COORD' ) + endif error = nf90_def_var(ncid, 'alnwf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnwf) call netcdf_err(error, 'DEFINING ALNWF' ) @@ -2193,6 +2199,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alnwf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALNWF COORD' ) + if(fract_grid)then error = nf90_def_var(ncid, 'alnwf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnwf_nl) call netcdf_err(error, 'DEFINING ALNWF_NL' ) error = nf90_put_att(ncid, id_alnwf_nl, "long_name", "alnwf_nl") @@ -2201,6 +2208,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ALNWF_NL UNITS' ) error = nf90_put_att(ncid, id_alnwf_nl, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALNWF_NL COORD' ) + endif error = nf90_def_var(ncid, 'facsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_facsf) call netcdf_err(error, 'DEFINING FACSF' ) @@ -2856,6 +2864,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALNSF RECORD' ) endif + if(fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID ALNSF_NL FOR TILE: ", tile call ESMF_FieldGather(alnsf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2866,6 +2875,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_alnsf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING ALNSF_NL RECORD' ) endif + endif print*,"- CALL FieldGather FOR TARGET GRID ALNWF FOR TILE: ", tile call ESMF_FieldGather(alnwf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) @@ -2878,6 +2888,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALNWF RECORD' ) endif + if(fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID ALNWF_NL FOR TILE: ", tile call ESMF_FieldGather(alnwf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2888,6 +2899,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_alnwf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING ALNWF_NL RECORD' ) endif + endif print*,"- CALL FieldGather FOR TARGET GRID ALVSF FOR TILE: ", tile call ESMF_FieldGather(alvsf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) @@ -2900,6 +2912,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALVSF RECORD' ) endif + if(fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID ALVSF_NL FOR TILE: ", tile call ESMF_FieldGather(alvsf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2910,6 +2923,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_alvsf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING ALVSF_NL RECORD' ) endif + endif print*,"- CALL FieldGather FOR TARGET GRID ALVWF FOR TILE: ", tile call ESMF_FieldGather(alvwf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) @@ -2922,6 +2936,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALVWF RECORD' ) endif + if(fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID ALVWF_NL FOR TILE: ", tile call ESMF_FieldGather(alvwf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2932,6 +2947,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_alvwf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING ALVWF_NL RECORD' ) endif + endif print*,"- CALL FieldGather FOR TARGET GRID MAX VEGETATION GREENNESS FOR TILE: ", tile call ESMF_FieldGather(max_veg_greenness_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) From efce786c1c4185c83140b7346583fdcee869f499 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 14 Mar 2022 19:00:08 +0000 Subject: [PATCH 012/107] Compute additional z0 fields when 'fract_grid' is true. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 55 ++++++++++++++++++++++-------- sorc/chgres_cube.fd/write_data.F90 | 14 ++++++++ 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 056601542..cc3cb21ec 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -1007,9 +1007,16 @@ subroutine interp(localpet) bundle_water_input = ESMF_FieldBundleCreate(name="water input", rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleCreate", rc) + + if(fract_grid)then call ESMF_FieldBundleAdd(bundle_water_target, (/sst_target_grid, z0_water_target_grid/), rc=rc) + else + call ESMF_FieldBundleAdd(bundle_water_target, (/sst_target_grid, z0_target_grid/), rc=rc) + endif + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) + call ESMF_FieldBundleAdd(bundle_water_input, (/skin_temp_input_grid, z0_input_grid/), rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) @@ -2251,6 +2258,7 @@ subroutine roughness use model_grid, only : landmask_target_grid use static_data, only : veg_type_target_grid + use program_setup, only : fract_grid implicit none @@ -2287,23 +2295,38 @@ subroutine roughness if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - print*,"- CALL FieldGet FOR TARGET GRID Z0 ICE." - call ESMF_FieldGet(z0_ice_target_grid, & - farrayPtr=data_ptr2, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) + if(fract_grid)then + print*,"- CALL FieldGet FOR TARGET GRID Z0 ICE." + call ESMF_FieldGet(z0_ice_target_grid, & + farrayPtr=data_ptr2, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) !cfract should check for fice instead? under fractional !cfract grids need to preserve original landmask_target. - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 2) then - data_ptr2(i,j) = 1.0 - elseif (landmask_ptr(i,j) == 1) then - data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0 - endif - enddo - enddo + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 2) then + data_ptr2(i,j) = 1.0 + endif + enddo + enddo + + else + +!cfract should check for fice instead? under fractional +!cfract grids need to preserve original landmask_target. + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 2) then + data_ptr(i,j) = 1.0 + elseif (landmask_ptr(i,j) == 1) then + data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0 + endif + enddo + enddo + + endif end subroutine roughness @@ -3210,6 +3233,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val + if (fract_grid)then print*,"- CALL FieldCreate FOR TARGET GRID Z0_ICE." z0_ice_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3241,6 +3265,7 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr = init_val + endif print*,"- CALL FieldCreate FOR INTERPOLATED TARGET GRID TERRAIN." terrain_from_input_grid = ESMF_FieldCreate(target_grid, & @@ -3828,6 +3853,8 @@ subroutine cleanup_target_sfc_data call ESMF_FieldDestroy(canopy_mc_target_grid, rc=rc) call ESMF_FieldDestroy(lai_target_grid,rc=rc) call ESMF_FieldDestroy(z0_target_grid, rc=rc) + if (ESMF_FieldIsCreated(z0_ice_target_grid)) call ESMF_FieldDestroy(z0_ice_target_grid, rc=rc) + if (ESMF_FieldIsCreated(z0_water_target_grid)) call ESMF_FieldDestroy(z0_water_target_grid, rc=rc) call ESMF_FieldDestroy(terrain_from_input_grid, rc=rc) call ESMF_FieldDestroy(terrain_from_input_grid_land, rc=rc) call ESMF_FieldDestroy(soil_type_from_input_grid, rc=rc) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 2fdfdba31..d4100a61d 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -2103,6 +2103,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_tg3, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TG3 COORD' ) + if(.not.fract_grid)then + error = nf90_def_var(ncid, 'zorl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl) + call netcdf_err(error, 'DEFINING ZORL' ) + error = nf90_put_att(ncid, id_zorl, "long_name", "zorl") + call netcdf_err(error, 'DEFINING ZORL LONG NAME' ) + error = nf90_put_att(ncid, id_zorl, "units", "none") + call netcdf_err(error, 'DEFINING ZORL UNITS' ) + error = nf90_put_att(ncid, id_zorl, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING ZORL COORD' ) + + else error = nf90_def_var(ncid, 'zorll', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl) call netcdf_err(error, 'DEFINING ZORLL' ) error = nf90_put_att(ncid, id_zorl, "long_name", "zorll") @@ -2129,6 +2140,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ZORL UNITS' ) error = nf90_put_att(ncid, id_zorl_water, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ZORL COORD' ) + endif error = nf90_def_var(ncid, 'alvsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvsf) call netcdf_err(error, 'DEFINING ALVSF' ) @@ -2741,6 +2753,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING Z0 RECORD' ) endif + if(fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID Z0_ICE FOR TILE: ", tile call ESMF_FieldGather(z0_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2762,6 +2775,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_zorl_water, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING Z0_WATER RECORD' ) endif + endif print*,"- CALL FieldGather FOR TARGET GRID MAX SNOW ALBEDO FOR TILE: ", tile call ESMF_FieldGather(mxsno_albedo_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) From c763c73827ce7aa96962b914d809cb5145ac44f3 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 14 Mar 2022 20:38:57 +0000 Subject: [PATCH 013/107] Output sea ice column temperature when 'fract_grid' is true. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 18 +++++++++++++++++- sorc/chgres_cube.fd/write_data.F90 | 20 ++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index cc3cb21ec..27b3e2c7c 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -881,6 +881,7 @@ subroutine interp(localpet) isrctermprocessing = 1 print*,"- CALL FieldRegridStore for 3d seaice fields." + if(fract_grid)then call ESMF_FieldRegridStore(soil_temp_input_grid, & ice_temp_target_grid, & srcmaskvalues=(/0/), & @@ -892,6 +893,19 @@ subroutine interp(localpet) routehandle=regrid_seaice, & regridmethod=method, & unmappedDstList=unmapped_ptr, rc=rc) + else + call ESMF_FieldRegridStore(soil_temp_input_grid, & + soil_temp_target_grid, & + srcmaskvalues=(/0/), & + dstmaskvalues=(/0/), & + polemethod=ESMF_POLEMETHOD_NONE, & + srctermprocessing=isrctermprocessing, & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & + normtype=ESMF_NORMTYPE_FRACAREA, & + routehandle=regrid_seaice, & + regridmethod=method, & + unmappedDstList=unmapped_ptr, rc=rc) + endif if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldRegridStore", rc) @@ -909,7 +923,7 @@ subroutine interp(localpet) else call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_target_grid, & snow_liq_equiv_target_grid, seaice_skin_temp_target_grid, & - ice_temp_target_grid/), rc=rc) + soil_temp_target_grid/), rc=rc) endif if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -3299,6 +3313,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val + if(fract_grid)then print*,"- CALL FieldCreate FOR TARGET GRID sea ice column TEMPERATURE." ice_temp_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3316,6 +3331,7 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr_3d = init_val + endif print*,"- CALL FieldCreate FOR TARGET GRID SOIL TEMPERATURE." soil_temp_target_grid = ESMF_FieldCreate(target_grid, & diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index d4100a61d..a6cdf35dd 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -2469,14 +2469,16 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_slc, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SLC COORD' ) - error = nf90_def_var(ncid, 'stc_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_lsoil,dim_time/), id_stc_ice) - call netcdf_err(error, 'DEFINING STC_ICE' ) - error = nf90_put_att(ncid, id_stc_ice, "long_name", "stc_ice") - call netcdf_err(error, 'DEFINING STC_ICE LONG NAME' ) - error = nf90_put_att(ncid, id_stc_ice, "units", "none") - call netcdf_err(error, 'DEFINING STC_ICE UNITS' ) - error = nf90_put_att(ncid, id_stc_ice, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING STC_ICE COORD' ) + if(fract_grid)then + error = nf90_def_var(ncid, 'stc_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_lsoil,dim_time/), id_stc_ice) + call netcdf_err(error, 'DEFINING STC_ICE' ) + error = nf90_put_att(ncid, id_stc_ice, "long_name", "stc_ice") + call netcdf_err(error, 'DEFINING STC_ICE LONG NAME' ) + error = nf90_put_att(ncid, id_stc_ice, "units", "none") + call netcdf_err(error, 'DEFINING STC_ICE UNITS' ) + error = nf90_put_att(ncid, id_stc_ice, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING STC_ICE COORD' ) + endif if (convert_nst) then @@ -3144,6 +3146,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) ! ice temperature + if(fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID sea ice TEMPERATURE FOR TILE: ", tile call ESMF_FieldGather(ice_temp_target_grid, data_one_tile_3d, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -3154,6 +3157,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_stc_ice, dum3d, start=(/1,1,1,1/), count=(/i_target_out,j_target_out,lsoil_target,1/)) call netcdf_err(error, 'WRITING sea ice TEMP RECORD' ) endif + endif ! soil temperature From e9f2bfc5774b87d82020f017e7b84ee726f4f5bd Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 15 Mar 2022 12:39:10 +0000 Subject: [PATCH 014/107] Output seperate skin temperatures for land/nonland when 'fract_grid' is true. Fixes #123 --- sorc/chgres_cube.fd/surface.F90 | 33 +++++++++++++++++++++++++++++- sorc/chgres_cube.fd/write_data.F90 | 13 ++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 27b3e2c7c..9d44718fc 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -1001,6 +1001,7 @@ subroutine interp(localpet) isrctermprocessing = 1 print*,"- CALL FieldRegridStore for water fields." + if(fract_grid)then call ESMF_FieldRegridStore(skin_temp_input_grid, & sst_target_grid, & srcmaskvalues=(/0/), & @@ -1012,6 +1013,19 @@ subroutine interp(localpet) routehandle=regrid_water, & regridmethod=method, & unmappedDstList=unmapped_ptr, rc=rc) + else + call ESMF_FieldRegridStore(skin_temp_input_grid, & + skin_temp_target_grid, & + srcmaskvalues=(/0/), & + dstmaskvalues=(/0/), & + polemethod=ESMF_POLEMETHOD_NONE, & + srctermprocessing=isrctermprocessing, & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & + normtype=ESMF_NORMTYPE_FRACAREA, & + routehandle=regrid_water, & + regridmethod=method, & + unmappedDstList=unmapped_ptr, rc=rc) + endif if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldRegridStore", rc) @@ -1025,7 +1039,7 @@ subroutine interp(localpet) if(fract_grid)then call ESMF_FieldBundleAdd(bundle_water_target, (/sst_target_grid, z0_water_target_grid/), rc=rc) else - call ESMF_FieldBundleAdd(bundle_water_target, (/sst_target_grid, z0_target_grid/), rc=rc) + call ESMF_FieldBundleAdd(bundle_water_target, (/skin_temp_target_grid, z0_target_grid/), rc=rc) endif if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2664,6 +2678,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) + if(fract_grid)then do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) > 0.0) then @@ -2675,6 +2690,19 @@ subroutine qc_check endif enddo enddo + else + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) > 0.0) then + skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + & + ( (1.0 - fice_ptr(i,j)) * frz_ice ) + else + seaice_skint_ptr(i,j) = skint_ptr(i,j) + hice_ptr(i,j) = 0.0 + endif + enddo + enddo + endif print*,"- SET TARGET GRID SUBSTRATE TEMP AT ICE." call ESMF_FieldGet(substrate_temp_target_grid, & @@ -3069,6 +3097,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val + if(fract_grid)then print*,"- CALL FieldCreate FOR TARGET GRID sst." sst_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3084,6 +3113,7 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr = init_val + endif print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE SKIN TEMP." seaice_skin_temp_target_grid = ESMF_FieldCreate(target_grid, & @@ -3866,6 +3896,7 @@ subroutine cleanup_target_sfc_data call ESMF_FieldDestroy(seaice_skin_temp_target_grid, rc=rc) call ESMF_FieldDestroy(srflag_target_grid, rc=rc) call ESMF_FieldDestroy(skin_temp_target_grid, rc=rc) + if (ESMF_FieldIsCreated(sst_target_grid)) call ESMF_FieldDestroy(sst_target_grid, rc=rc) call ESMF_FieldDestroy(canopy_mc_target_grid, rc=rc) call ESMF_FieldDestroy(lai_target_grid,rc=rc) call ESMF_FieldDestroy(z0_target_grid, rc=rc) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index a6cdf35dd..410bb388a 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -2056,6 +2056,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_slmsk, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SLMSK COORD' ) + if(fract_grid)then error = nf90_def_var(ncid, 'tsfcl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tsfcl) call netcdf_err(error, 'DEFINING TSFCL' ) error = nf90_put_att(ncid, id_tsfcl, "long_name", "tsfcl") @@ -2064,6 +2065,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING TSFCL UNITS' ) error = nf90_put_att(ncid, id_tsfcl, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TSFCL COORD' ) + endif error = nf90_def_var(ncid, 'tsea', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tsea) call netcdf_err(error, 'DEFINING TSEA' ) @@ -3107,10 +3109,16 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - error = nf90_put_var( ncid, id_tsfcl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING TSFCL RECORD' ) + if(fract_grid)then + error = nf90_put_var( ncid, id_tsfcl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING TSFCL RECORD' ) + else + error = nf90_put_var( ncid, id_tsea, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING TSFC RECORD' ) + endif endif + if(fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID sst FOR TILE: ", tile call ESMF_FieldGather(sst_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -3121,6 +3129,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_tsea, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING TSEA RECORD' ) endif + endif print*,"- CALL FieldGather FOR TARGET GRID LANDMASK FOR TILE: ", tile call ESMF_FieldGather(landmask_target_grid, idata_one_tile, rootPet=0, tile=tile, rc=error) From 8b403546f3c1d6ef1971747d4437d329c664f814 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 15 Mar 2022 20:22:25 +0000 Subject: [PATCH 015/107] Change the definition of some interpolation mask arrays to work better with fractional grids. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 9d44718fc..31bcf2866 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -862,18 +862,13 @@ subroutine interp(localpet) mask_input_ptr = 0 where (nint(landmask_input_ptr) == 2) mask_input_ptr = 1 - print*,"- CALL FieldGet FOR TARGET land sea mask." - call ESMF_FieldGet(landmask_target_grid, & - farrayPtr=landmask_target_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) +!cfract Instead, check if 'fice' is non-zero to set +!cfract mask_target_ptr. -!cfract Instead, should I check if 'fice' is non-zero to set -!cfract mask_target_ptr? mask_target_ptr = 0 do j = clb_target(2), cub_target(2) do i = clb_target(1), cub_target(1) - if (landmask_target_ptr(i,j) == 2) mask_target_ptr(i,j) = 1 + if (seaice_fract_target_ptr(i,j) > 0.0) mask_target_ptr(i,j) = 1 enddo enddo @@ -994,8 +989,10 @@ subroutine interp(localpet) !cfract use seamask_target, which is 1 if there is some water. !cfract then remove points where fice is > 0. !cfract We want points with at least some water, but no ice. + mask_target_ptr = 0 - where (landmask_target_ptr == 0) mask_target_ptr = 1 + where (seamask_target_ptr == 1) mask_target_ptr = 1 + where (seaice_fract_target_ptr > 0.0) mask_target_ptr = 0 method=ESMF_REGRIDMETHOD_CONSERVE isrctermprocessing = 1 From 18da98fe656725e546840839897132975712b4ae Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 16 Mar 2022 18:21:24 +0000 Subject: [PATCH 016/107] Check for ice using 'fice' array instead of land mask array. Using the land mask array will not work with fractional grids. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 31bcf2866..ab87fb2e8 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2293,6 +2293,7 @@ subroutine roughness real :: z0_igbp(20) real(esmf_kind_r8), pointer :: data_ptr(:,:) real(esmf_kind_r8), pointer :: data_ptr2(:,:) + real(esmf_kind_r8), pointer :: fice_ptr(:,:) real(esmf_kind_r8), pointer :: veg_type_ptr(:,:) data z0_igbp /1.089, 2.653, 0.854, 0.826, 0.800, 0.050, & @@ -2308,6 +2309,12 @@ subroutine roughness if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) + print*,"- CALL FieldGet FOR TARGET GRID SEA ICE." + call ESMF_FieldGet(seaice_fract_target_grid, & + farrayPtr=fice_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + print*,"- CALL FieldGet FOR TARGET GRID VEGETATION TYPE." call ESMF_FieldGet(veg_type_target_grid, & farrayPtr=veg_type_ptr, rc=rc) @@ -2321,6 +2328,7 @@ subroutine roughness call error_handler("IN FieldGet", rc) if(fract_grid)then + print*,"- CALL FieldGet FOR TARGET GRID Z0 ICE." call ESMF_FieldGet(z0_ice_target_grid, & farrayPtr=data_ptr2, rc=rc) @@ -2331,19 +2339,19 @@ subroutine roughness !cfract grids need to preserve original landmask_target. do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 2) then + if (fice_ptr(i,j) > 0.0) then data_ptr2(i,j) = 1.0 endif enddo enddo - else + else ! non-fractional grid !cfract should check for fice instead? under fractional !cfract grids need to preserve original landmask_target. do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 2) then + if (fice_ptr(i,j) > 0.0) then data_ptr(i,j) = 1.0 elseif (landmask_ptr(i,j) == 1) then data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0 @@ -2710,7 +2718,7 @@ subroutine qc_check !cfract don't use the '2' flag for ice. Use fice instead? do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 2) then ! sea ice + if (fice_ptr(i,j) > 0.0) then ! sea ice data_ptr(i,j) = frz_ice elseif (landmask_ptr(i,j) == 0) then ! open water flag value. data_ptr(i,j) = skint_ptr(i,j) @@ -2763,7 +2771,7 @@ subroutine qc_check !cfract replace check of '2' with fice? do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 2 .or. landmask_ptr(i,j) == 0 .or. & + if (fice_ptr(i,j) > 0.0 .or. landmask_ptr(i,j) == 0 .or. & nint(veg_type_ptr(i,j)) == veg_type_landice_target) then soilmt_ptr(i,j,:) = 1.0 soilml_ptr(i,j,:) = 1.0 From 0cc5797f3c775fa6308e1571c62dbfcc52a98072 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 16 Mar 2022 19:08:29 +0000 Subject: [PATCH 017/107] Replace another ice check so that it works for fractional and non-fractional grids. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index ab87fb2e8..6c78acd39 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -422,6 +422,7 @@ subroutine interp(localpet) real(esmf_kind_r8), allocatable :: data_one_tile2(:,:) real(esmf_kind_r8), allocatable :: data_one_tile_3d(:,:,:) real(esmf_kind_r8), allocatable :: latitude_one_tile(:,:) + real(esmf_kind_r8), allocatable :: fice_target_one_tile(:,:) real(esmf_kind_r8), pointer :: seaice_fract_target_ptr(:,:) real(esmf_kind_r8), pointer :: srflag_target_ptr(:,:) real(esmf_kind_r8), pointer :: terrain_from_input_ptr(:,:) @@ -950,6 +951,12 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleDestroy", rc) + if (localpet == 0) then + allocate(fice_target_one_tile(i_target,j_target)) + else + allocate(fice_target_one_tile(0,0)) + endif + do tile = 1, num_tiles_target_grid print*,"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile @@ -957,18 +964,23 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) + print*,"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile + call ESMF_FieldGather(seaice_fract_target_grid, fice_target_one_tile, rootPet=0, tile=tile, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", rc) + !cfract using ice flag of '2' here. cant do that. if (localpet == 0) then where(mask_target_one_tile == 1) mask_target_one_tile = 0 - where(mask_target_one_tile == 2) mask_target_one_tile = 1 + where(fice_target_one_tile > 0.0) mask_target_one_tile = 1 endif - call search_many(num_fields,bundle_seaice_target,data_one_tile, mask_target_one_tile,tile,search_nums,localpet, & field_data_3d=data_one_tile_3d) enddo - deallocate(search_nums) + deallocate(search_nums, fice_target_one_tile) + call ESMF_FieldBundleDestroy(bundle_seaice_target,rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldBundleDestroy", rc) From c424675b1c88dcc144f3ef05513e37bc1a556575 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 17 Mar 2022 20:10:41 +0000 Subject: [PATCH 018/107] Replace more ice checks so it will work with fractional grids. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 48 ++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 6c78acd39..7dd4ffafc 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -827,7 +827,7 @@ subroutine interp(localpet) data_one_tile(i,j) = 1.0_esmf_kind_r8 endif if (data_one_tile(i,j) < 0.15_esmf_kind_r8) data_one_tile(i,j) = 0.0_esmf_kind_r8 - if (data_one_tile(i,j) >= 0.15_esmf_kind_r8) mask_target_one_tile(i,j) = 2 +! if (data_one_tile(i,j) >= 0.15_esmf_kind_r8) mask_target_one_tile(i,j) = 2 enddo enddo endif @@ -979,7 +979,8 @@ subroutine interp(localpet) field_data_3d=data_one_tile_3d) enddo - deallocate(search_nums, fice_target_one_tile) + !deallocate(search_nums, fice_target_one_tile) + deallocate(search_nums) call ESMF_FieldBundleDestroy(bundle_seaice_target,rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& @@ -1117,6 +1118,11 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) + print*,"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile + call ESMF_FieldGather(seaice_fract_target_grid, fice_target_one_tile, rootPet=0, tile=tile, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", rc) + print*,"- CALL FieldGather FOR TARGET LATITUDE TILE: ", tile call ESMF_FieldGather(latitude_target_grid, latitude_one_tile, rootPet=0, tile=tile, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -1127,6 +1133,7 @@ subroutine interp(localpet) allocate(water_target_one_tile(i_target,j_target)) water_target_one_tile = 0 where(mask_target_one_tile == 0) water_target_one_tile = 1 + where(fice_target_one_tile > 0.0) water_target_one_tile = 0 endif call search_many(num_fields,bundle_water_target,data_one_tile, water_target_one_tile,& @@ -1136,7 +1143,7 @@ subroutine interp(localpet) enddo - deallocate(latitude_one_tile,search_nums) + deallocate(latitude_one_tile,search_nums,fice_target_one_tile) call ESMF_FieldBundleDestroy(bundle_water_target,rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2423,6 +2430,12 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) + print*,"- CALL FieldGet FOR TARGET GRID SEA ICE FRACTION." + call ESMF_FieldGet(seaice_fract_target_grid, & + farrayPtr=fice_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + print*,"- SET NON-LAND FLAG FOR TARGET GRID SLOPE TYPE." call ESMF_FieldGet(slope_type_target_grid, & farrayPtr=data_ptr, rc=rc) @@ -2683,12 +2696,6 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - print*,"- CALL FieldGet FOR TARGET GRID SEA ICE FRACTION." - call ESMF_FieldGet(seaice_fract_target_grid, & - farrayPtr=fice_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - print*,"- SET TARGET GRID SEA ICE DEPTH TO ZERO AT NON-ICE POINTS." call ESMF_FieldGet(seaice_depth_target_grid, & farrayPtr=hice_ptr, rc=rc) @@ -2747,7 +2754,7 @@ subroutine qc_check !cfract this should work for fractional grids. do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0) then ! open water + if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then ! open water data_ptr(i,j) = 0.0 end if enddo @@ -2762,7 +2769,7 @@ subroutine qc_check !cfract this should work for fractional grids. do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0) then ! open water + if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then ! open water data_ptr(i,j) = 0.0 endif enddo @@ -2801,7 +2808,7 @@ subroutine qc_check !cfract sst_target_grid here. do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0) then + if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then data3d_ptr(i,j,:) = skint_ptr(i,j) ! open water flag value. endif enddo @@ -2828,6 +2835,7 @@ subroutine nst_land_fill integer, PARAMETER :: nst_fill = 0.0 real(esmf_kind_r8), pointer :: data_ptr(:,:) + real(esmf_kind_r8), pointer :: fice_ptr(:,:) real(esmf_kind_r8), pointer :: skint_ptr(:,:) type(esmf_field) :: temp_field @@ -2838,6 +2846,12 @@ subroutine nst_land_fill farrayPtr=mask_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldGet", rc) + + print*,"- CALL FieldGet FOR TARGET GRID LANDMASK." + call ESMF_FieldGet(seaice_fract_target_grid, & + farrayPtr=fice_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& + call error_handler("IN FieldGet", rc) nst_bundle = ESMF_FieldBundleCreate(name="nst_bundle", rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& @@ -2867,7 +2881,9 @@ subroutine nst_land_fill !cfract Under fractional grids use seamask_target, where =0 !cfract is all land. And use fice field for ice. !cfrac where(seamask_target == 0) .and where (fice > 0) data_ptr=skint_ptr - where(mask_ptr /= 0) data_ptr = skint_ptr + + where(mask_ptr == 1) data_ptr = skint_ptr + where(fice_ptr > 0.0) data_ptr = skint_ptr ! xz @@ -2878,7 +2894,8 @@ subroutine nst_land_fill call error_handler("IN FieldGet", rc) !cfract same as above. - where(mask_ptr /= 0) data_ptr = xz_fill + where(mask_ptr == 1) data_ptr = xz_fill + where(fice_ptr > 0.0) data_ptr = xz_fill do i = 1,num_nst_fields_minus2 @@ -2891,7 +2908,8 @@ subroutine nst_land_fill call error_handler("IN FieldGet", rc) !cfract same as above. - where(mask_ptr /= 0) data_ptr = nst_fill + where(mask_ptr == 1) data_ptr = nst_fill + where(fice_ptr > 0.0) data_ptr = nst_fill enddo From 37d5c5b95f061c444b3a7562f9be42027462f8c5 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 17 Mar 2022 20:59:35 +0000 Subject: [PATCH 019/107] Add subroutine to update the land mask for sea ice. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 7dd4ffafc..ce5f33380 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -297,6 +297,9 @@ subroutine surface_driver(localpet) if (convert_nst) call cleanup_input_nst_data + + call update_landmask + !--------------------------------------------------------------------------------------------- ! Write data to file. !--------------------------------------------------------------------------------------------- @@ -3611,6 +3614,48 @@ subroutine create_nst_esmf_fields end subroutine create_nst_esmf_fields +!> Update landmask for sea ice. +!! +!! @author George Gayno + subroutine update_landmask + + use model_grid, only : landmask_target_grid + + use program_setup, only : fract_grid + + implicit none + + integer :: rc + integer(esmf_kind_i8), pointer :: mask_ptr(:,:) + + real(esmf_kind_r8), pointer :: ice_ptr(:,:) + + print*,"- UPDATE TARGET LANDMASK WITH ICE RECORD." + + print*,"- INITIALIZE TARGET grid sea ice fraction." + call ESMF_FieldGet(seaice_fract_target_grid, & + farrayPtr=ice_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + print*,"- INITIALIZE TARGET landmask." + call ESMF_FieldGet(landmask_target_grid, & + farrayPtr=mask_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + if (.not.fract_grid) then + + where(ice_ptr > 0.0) mask_ptr = 2 + + else + + print*,'add mask logic for fractional grid' + + endif + + end subroutine update_landmask + !> Convert 1d index to 2d indices. !! !! @param[in] ij the 1d index From b57fd5563fcb0e13cad4d2e286a726301fc6466d Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 17 Mar 2022 21:31:55 +0000 Subject: [PATCH 020/107] Remove some obsolete code. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index ce5f33380..fde90a709 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -816,12 +816,6 @@ subroutine interp(localpet) call search(data_one_tile, mask_target_one_tile, i_target, j_target, tile, 91, & latitude=latitude_one_tile) endif - - print*,"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile - call ESMF_FieldGather(landmask_target_grid, mask_target_one_tile, rootPet=0, tile=tile, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGather", rc) - if (localpet == 0) then do j = 1, j_target @@ -830,7 +824,6 @@ subroutine interp(localpet) data_one_tile(i,j) = 1.0_esmf_kind_r8 endif if (data_one_tile(i,j) < 0.15_esmf_kind_r8) data_one_tile(i,j) = 0.0_esmf_kind_r8 -! if (data_one_tile(i,j) >= 0.15_esmf_kind_r8) mask_target_one_tile(i,j) = 2 enddo enddo endif @@ -840,15 +833,6 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldScatter", rc) -!cfrac -! under fractional grid, landmask_target_grid is '1' if there is at least some -! land and '0' if all water. Updating to points to '2' will have consequences -! later. Don't do this? - print*,"- CALL FieldScatter FOR TARGET LANDMASK TILE: ", tile - call ESMF_FieldScatter(landmask_target_grid, mask_target_one_tile, rootPet=0, tile=tile, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldScatter", rc) - enddo deallocate(latitude_one_tile) From 4ff062426d59c680b9da04c6866405a631704e85 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 23 Mar 2022 14:00:13 +0000 Subject: [PATCH 021/107] Uncomment calculation of sea and land mask for fractional grids. Fixes #123. --- sorc/chgres_cube.fd/model_grid.F90 | 10 +++++----- sorc/chgres_cube.fd/surface.F90 | 17 ++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/sorc/chgres_cube.fd/model_grid.F90 b/sorc/chgres_cube.fd/model_grid.F90 index e8b6cd8ea..c2fa40f9c 100644 --- a/sorc/chgres_cube.fd/model_grid.F90 +++ b/sorc/chgres_cube.fd/model_grid.F90 @@ -1330,13 +1330,13 @@ subroutine define_target_grid(localpet, npets) terrain_one_tile, land_frac_one_tile) if (fract_grid) then -! seamask_one_tile = 0 ! all land -! where(floor(land_frac_one_tile) == 0) seamask_one_tile = 1 ! at least some water -! landmask_one_tile = 0 ! all water -! where(ceiling(land_frac_one_tile) == 1) landmask_one_tile = 1 ! at least some land + seamask_one_tile = 0 ! all land + where(floor(land_frac_one_tile) == 0) seamask_one_tile = 1 ! at least some non-land. + landmask_one_tile = 0 ! all non-land + where(ceiling(land_frac_one_tile) == 1) landmask_one_tile = 1 ! at least some land else seamask_one_tile = 0 ! all land - where(landmask_one_tile == 0) seamask_one_tile=1 + where(landmask_one_tile == 0) seamask_one_tile=1 ! not land endif call get_model_latlons(mosaic_file_target_grid, orog_dir_target_grid, num_tiles_target_grid, tile, & diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index fde90a709..e8822d136 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -730,15 +730,17 @@ subroutine interp(localpet) !----------------------------------------------------------------------- ! Next, determine the sea ice fraction on target grid. -! Interpolate. +! For fractional grids, the ice fraction is not scaled for the +! fraction of non-land. So if a point is 50% land and non-land, +! an ice frac of 100% means the entire non-land portion is ice covered. !----------------------------------------------------------------------- mask_input_ptr = 1 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 0 -!cfract -!cfract under fractional grid, seamask_target will be '1' if there is -!cfract at least some water. +! For non-fractional grids, 'seamask_target_ptr' is '1' for land points +! and '0' for non-land points. For fractional grids, 'seamask_target_ptr' +! will be '0' if all land and '1' is at least some non-land. mask_target_ptr = seamask_target_ptr @@ -793,10 +795,6 @@ subroutine interp(localpet) do tile = 1, num_tiles_target_grid -!cfract according to Shan, the ice fraction is not scaled for -!cfract the fraction of non-land. So if a point is 50% -!cfract land and non-land, an ice frac to 100% means the -!cfract entire non-land portion is ice covered. print*,"- CALL FieldGather FOR TARGET GRID SEAICE FRACTION TILE: ", tile call ESMF_FieldGather(seaice_fract_target_grid, data_one_tile, rootPet=0, tile=tile, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -850,9 +848,6 @@ subroutine interp(localpet) mask_input_ptr = 0 where (nint(landmask_input_ptr) == 2) mask_input_ptr = 1 -!cfract Instead, check if 'fice' is non-zero to set -!cfract mask_target_ptr. - mask_target_ptr = 0 do j = clb_target(2), cub_target(2) do i = clb_target(1), cub_target(1) From 5852988942da2e56a3c650a6a5c436506b2a9560 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 5 Apr 2022 17:56:03 +0000 Subject: [PATCH 022/107] Add definition of 'slmsk' for fractional grids. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index e8822d136..6b37e2232 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -3598,26 +3598,27 @@ end subroutine create_nst_esmf_fields !! @author George Gayno subroutine update_landmask - use model_grid, only : landmask_target_grid + use model_grid, only : landmask_target_grid, land_frac_target_grid use program_setup, only : fract_grid implicit none - integer :: rc + integer :: i, j, rc, clb(2), cub(2) integer(esmf_kind_i8), pointer :: mask_ptr(:,:) real(esmf_kind_r8), pointer :: ice_ptr(:,:) + real(esmf_kind_r8), pointer :: land_frac_ptr(:,:) print*,"- UPDATE TARGET LANDMASK WITH ICE RECORD." - print*,"- INITIALIZE TARGET grid sea ice fraction." + print*,"- GET TARGET grid sea ice fraction." call ESMF_FieldGet(seaice_fract_target_grid, & farrayPtr=ice_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - print*,"- INITIALIZE TARGET landmask." + print*,"- GET TARGET landmask." call ESMF_FieldGet(landmask_target_grid, & farrayPtr=mask_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -3629,7 +3630,25 @@ subroutine update_landmask else - print*,'add mask logic for fractional grid' + print*,"- GET TARGET land fraction." + call ESMF_FieldGet(land_frac_target_grid, & + computationalLBound=clb, & + computationalUBound=cub, & + farrayPtr=land_frac_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + do j = clb(2), cub(2) + do i = clb(1), cub(1) + + if(ice_ptr(i,j) > 0.0) then + mask_ptr(i,j) = 2 + else + mask_ptr(i,j) = int(land_frac_ptr(i,j)) + endif + + enddo + enddo endif From 40279c73fd376e4bac5bda39dc4312017d751f27 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 5 Apr 2022 21:08:55 +0000 Subject: [PATCH 023/107] Fix setting of roughness at land for coupled grids. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 6b37e2232..0fa4859ab 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -738,8 +738,8 @@ subroutine interp(localpet) mask_input_ptr = 1 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 0 -! For non-fractional grids, 'seamask_target_ptr' is '1' for land points -! and '0' for non-land points. For fractional grids, 'seamask_target_ptr' +! For non-fractional grids, 'seamask_target_ptr' is '0' for land points +! and '1' for non-land points. For fractional grids, 'seamask_target_ptr' ! will be '0' if all land and '1' is at least some non-land. mask_target_ptr = seamask_target_ptr @@ -2336,8 +2336,6 @@ subroutine roughness if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract should check for fice instead? under fractional -!cfract grids need to preserve original landmask_target. do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) > 0.0) then @@ -2346,6 +2344,16 @@ subroutine roughness enddo enddo + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 1) then + data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0 + else + data_ptr(i,j) = -9. + endif + enddo + enddo + else ! non-fractional grid !cfract should check for fice instead? under fractional From 3759e049587c9762fb479bb2f13ad6ac8b449e2e Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 6 Apr 2022 14:54:47 +0000 Subject: [PATCH 024/107] Fix soil moisture flag value at non-land points when processing fractional grids. Fixes #123 --- sorc/chgres_cube.fd/surface.F90 | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 0fa4859ab..4a0da5288 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2777,22 +2777,33 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract replace check of '2' with fice? - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) > 0.0 .or. landmask_ptr(i,j) == 0 .or. & - nint(veg_type_ptr(i,j)) == veg_type_landice_target) then - soilmt_ptr(i,j,:) = 1.0 - soilml_ptr(i,j,:) = 1.0 - endif - enddo - enddo + if (fract_grid) then + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0 .or. & + nint(veg_type_ptr(i,j)) == veg_type_landice_target) then + soilmt_ptr(i,j,:) = 1.0 + soilml_ptr(i,j,:) = 1.0 + endif + enddo + enddo + else + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) > 0.0 .or. landmask_ptr(i,j) == 0 .or. & + nint(veg_type_ptr(i,j)) == veg_type_landice_target) then + soilmt_ptr(i,j,:) = 1.0 + soilml_ptr(i,j,:) = 1.0 + endif + enddo + enddo + endif print*,"- SET OPEN WATER FLAG FOR TARGET GRID SOIL TEMPERATURE." call ESMF_FieldGet(soil_temp_target_grid, & farrayPtr=data3d_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) + call error_handler("IN FieldGet", rc) !cfract, is skint_ptr the new sst field? need to use new !cfract sst_target_grid here. From 2d2bc3faf2dc845d60db987385d6d8c5b80a07dc Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 6 Apr 2022 15:57:30 +0000 Subject: [PATCH 025/107] When processing fractional grids, output a separate record for ice substrate temperature. Fixes #123 --- sorc/chgres_cube.fd/surface.F90 | 44 +++++++++++++++++++++++++++++- sorc/chgres_cube.fd/write_data.F90 | 29 +++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 4a0da5288..7f0020dec 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -57,6 +57,8 @@ module surface !< sea ice fraction type(esmf_field), public :: seaice_skin_temp_target_grid !< sea ice skin temperature + type(esmf_field), public :: seaice_substrate_temp_target_grid + !< sea ice substrate temperature type(esmf_field), public :: skin_temp_target_grid !< skin temperature/sst type(esmf_field), public :: sst_target_grid @@ -2719,12 +2721,29 @@ subroutine qc_check endif print*,"- SET TARGET GRID SUBSTRATE TEMP AT ICE." + + if (fract_grid) then + + call ESMF_FieldGet(seaice_substrate_temp_target_grid, & + farrayPtr=data_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) > 0.0) then ! sea ice + data_ptr(i,j) = frz_ice + endif + enddo + enddo + + else + call ESMF_FieldGet(substrate_temp_target_grid, & farrayPtr=data_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract don't use the '2' flag for ice. Use fice instead? do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) > 0.0) then ! sea ice @@ -2735,6 +2754,8 @@ subroutine qc_check enddo enddo + endif + print*,"- ZERO OUT TARGET GRID SNOW DEPTH AT OPEN WATER." call ESMF_FieldGet(snow_depth_target_grid, & farrayPtr=data_ptr, rc=rc) @@ -3167,6 +3188,26 @@ subroutine create_surface_esmf_fields target_ptr = init_val + if (fract_grid) then + + print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE SUBSTRATE TEMP." + seaice_substrate_temp_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + name="seaice_substrate_temp_target_grid", & + staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldCreate", rc) + + print*,"- INITIALIZE TARGET sea ice substrate temp." + call ESMF_FieldGet(seaice_substrate_temp_target_grid, & + farrayPtr=target_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + target_ptr = init_val + + endif + print*,"- CALL FieldCreate FOR TARGET GRID SRFLAG." srflag_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3991,6 +4032,7 @@ subroutine cleanup_target_sfc_data call ESMF_FieldDestroy(seaice_fract_target_grid, rc=rc) call ESMF_FieldDestroy(seaice_depth_target_grid, rc=rc) call ESMF_FieldDestroy(seaice_skin_temp_target_grid, rc=rc) + if (ESMF_FieldIsCreated(seaice_substrate_temp_target_grid)) call ESMF_FieldDestroy(seaice_substrate_temp_target_grid, rc=rc) call ESMF_FieldDestroy(srflag_target_grid, rc=rc) call ESMF_FieldDestroy(skin_temp_target_grid, rc=rc) if (ESMF_FieldIsCreated(sst_target_grid)) call ESMF_FieldDestroy(sst_target_grid, rc=rc) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 410bb388a..5f2c6e164 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1827,6 +1827,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) seaice_depth_target_grid, & seaice_fract_target_grid, & seaice_skin_temp_target_grid, & + seaice_substrate_temp_target_grid, & skin_temp_target_grid, & sst_target_grid, & soil_temp_target_grid, & @@ -1894,7 +1895,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: error, i, ncid, tile integer :: id_x, id_y, id_lsoil integer :: id_slmsk, id_time - integer :: id_lat, id_lon + integer :: id_lat, id_lon, id_tg3_ice integer :: id_tsfcl, id_tsea, id_sheleg, id_sheleg_ice, id_tg3 integer :: id_zorl, id_zorl_ice, id_alvsf, id_alvwf integer :: id_zorl_water, id_alvsf_nl @@ -2105,6 +2106,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_tg3, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TG3 COORD' ) + if(fract_grid)then + error = nf90_def_var(ncid, 'tg3_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3_ice) + call netcdf_err(error, 'DEFINING TG3_ICE' ) + error = nf90_put_att(ncid, id_tg3_ice, "long_name", "tg3_ice") + call netcdf_err(error, 'DEFINING TG3_ICE LONG NAME' ) + error = nf90_put_att(ncid, id_tg3_ice, "units", "none") + call netcdf_err(error, 'DEFINING TG3_ICE UNITS' ) + error = nf90_put_att(ncid, id_tg3_ice, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING TG3_ICE COORD' ) + endif + if(.not.fract_grid)then error = nf90_def_var(ncid, 'zorl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl) call netcdf_err(error, 'DEFINING ZORL' ) @@ -2849,6 +2861,21 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SUBSTRATE TEMPERATURE RECORD' ) endif + if(fract_grid) then + + print*,"- CALL FieldGather FOR TARGET GRID SEAICE SUBSTRATE TEMPERATURE FOR TILE: ", tile + call ESMF_FieldGather(seaice_substrate_temp_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_tg3_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING SEAICE SUBSTRATE TEMPERATURE RECORD' ) + endif + + endif + print*,"- CALL FieldGather FOR TARGET GRID FACSF FOR TILE: ", tile call ESMF_FieldGather(facsf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & From 0e87d84bdc98e5c5eadd6ae49c0fcfe819583999 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 7 Apr 2022 19:54:02 +0000 Subject: [PATCH 026/107] Read in fract_grid logical from program namelist. Fixes #123. --- sorc/chgres_cube.fd/program_setup.F90 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sorc/chgres_cube.fd/program_setup.F90 b/sorc/chgres_cube.fd/program_setup.F90 index c594a85ef..29449ae95 100644 --- a/sorc/chgres_cube.fd/program_setup.F90 +++ b/sorc/chgres_cube.fd/program_setup.F90 @@ -198,7 +198,8 @@ subroutine read_setup_namelist(filename) halo_blend, & fix_dir_input_grid, & nsoill_out, & - thomp_mp_climo_file + thomp_mp_climo_file, & + fract_grid print*,"- READ SETUP NAMELIST" @@ -350,6 +351,12 @@ subroutine read_setup_namelist(filename) print*,"- WILL PROCESS CLIMO THOMPSON MP TRACERS FROM FILE: ", trim(thomp_mp_climo_file) endif + if (fract_grid) then + print*,'WILL PROCESS A FRACTIONAL GRID.' + else + print*,'WILL PROCESS A NON-FRACTIONAL GRID.' + endif + return end subroutine read_setup_namelist From ce2685055f4a88f8fa357c99eff3120e1ed282b5 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 8 Apr 2022 19:58:28 +0000 Subject: [PATCH 027/107] Baseline a software tool to check the correctness of the fractional grid logic. Fixes #123. --- sorc/CMakeLists.txt | 1 + sorc/chgres_tools.fd/CMakeLists.txt | 16 +++ sorc/chgres_tools.fd/check.F90 | 210 ++++++++++++++++++++++++++++ 3 files changed, 227 insertions(+) create mode 100644 sorc/chgres_tools.fd/CMakeLists.txt create mode 100644 sorc/chgres_tools.fd/check.F90 diff --git a/sorc/CMakeLists.txt b/sorc/CMakeLists.txt index 282878ff5..a41b1e903 100644 --- a/sorc/CMakeLists.txt +++ b/sorc/CMakeLists.txt @@ -13,6 +13,7 @@ endif() add_subdirectory(fre-nctools.fd) add_subdirectory(grid_tools.fd) add_subdirectory(chgres_cube.fd) +add_subdirectory(chgres_tools.fd) add_subdirectory(orog_mask_tools.fd) add_subdirectory(sfc_climo_gen.fd) add_subdirectory(vcoord_gen.fd) diff --git a/sorc/chgres_tools.fd/CMakeLists.txt b/sorc/chgres_tools.fd/CMakeLists.txt new file mode 100644 index 000000000..367075dd7 --- /dev/null +++ b/sorc/chgres_tools.fd/CMakeLists.txt @@ -0,0 +1,16 @@ +set(fortran_src + check.F90) + +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8") +endif() + +set(exe_name chgres_check) +add_executable(${exe_name} ${fortran_src}) +target_link_libraries( + ${exe_name} + NetCDF::NetCDF_Fortran) + +install(TARGETS ${exe_name} RUNTIME DESTINATION ${exec_dir}) diff --git a/sorc/chgres_tools.fd/check.F90 b/sorc/chgres_tools.fd/check.F90 new file mode 100644 index 000000000..347aa00db --- /dev/null +++ b/sorc/chgres_tools.fd/check.F90 @@ -0,0 +1,210 @@ + program check + +! How to use. +! +! 1) Run chgres in fractional grid mode. +! +! 2) Run chgres again using the updated orography files where 'slmsk' is +! updated to be 'ceiling(land fraction)'. Here chgres is run +! in non-fractional mode. +! +! 3) Compare the fields at land from (2) to the fields with at least +! some land from (1). They should match. + + use netcdf + + implicit none + + integer, parameter :: num_var=27 + integer, parameter :: num_var3d=3 + + character(len=150) :: file_ceiling, file_frac, file_orog_frac + + character(len=15) :: varname(num_var), varname3d(num_var3d) + + integer :: error, id_dim, idim, jdim + integer :: varid, varid_ceil, varid_frac, var + integer :: i, j, n, ncid_ceil, ncid_orog_frac, ncid_frac + + real*8, allocatable :: slmsk(:,:), land_frac(:,:), dummy_frac(:,:) + real*8, allocatable :: dummy_ceil(:,:) + real*8, allocatable :: dummy_frac3d(:,:,:), dummy_ceil3d(:,:,:) + + data varname /'alvsf', 'alvwf', 'alnsf', 'alnwf', 'canopy', & + 'f10m' , 'facsf', 'facwf', 'ffhh' , 'ffmm', & + 'q2m' , 'shdmax','shdmin', 'sheleg', 'slope', & + 'snoalb', 'snwdph', 'srflag','stype', 't2m', & + 'tg3', 'tprcp', 'tsfcl', 'uustar', 'vfrac', & + 'vtype', 'zorll' / + + data varname3d /'stc', 'slc', 'smc'/ + + file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/out.sfc.tile1.nc" + file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/C96_oro_data.tile1.nc" + file_ceiling="/gpfs/dell1/stmp/George.Gayno/chgres_ceiling/out.sfc.tile1.nc" + +! Open the file created using the non-fractional logic, but with +! slmsk modified to be ceiling of the land fraction. + + error=nf90_open(trim(file_ceiling),nf90_nowrite,ncid_ceil) + call netcdf_err(error, 'opening file_ceiling' ) + + error=nf90_inq_dimid(ncid_ceil, 'xaxis_1', id_dim) + call netcdf_err(error, 'getting xaxis' ) + error=nf90_inquire_dimension(ncid_ceil,id_dim,len=idim) + call netcdf_err(error, 'reading xaxis' ) + + error=nf90_inq_dimid(ncid_ceil, 'yaxis_1', id_dim) + call netcdf_err(error, 'getting yaxis' ) + error=nf90_inquire_dimension(ncid_ceil,id_dim,len=jdim) + call netcdf_err(error, 'reading yaxis' ) + + allocate(slmsk(idim,jdim)) + + error=nf90_inq_varid(ncid_ceil,"slmsk",varid) + call netcdf_err(error, 'reading slmsk id' ) + error=nf90_get_var(ncid_ceil,varid,slmsk) + call netcdf_err(error, 'reading slmsk' ) + + print*,'slmsk ',maxval(slmsk),minval(slmsk) + +! Open the fractional grid orography file. Read the +! land fraction. + + error=nf90_open(trim(file_orog_frac),nf90_nowrite,ncid_orog_frac) + call netcdf_err(error, 'opening file_orog_frac' ) + + allocate(land_frac(idim,jdim)) + + error=nf90_inq_varid(ncid_orog_frac,"land_frac",varid_frac) + call netcdf_err(error, 'reading land_frac id' ) + error=nf90_get_var(ncid_orog_frac,varid_frac,land_frac) + call netcdf_err(error, 'reading land_frac' ) + + print*,'land_frac ',maxval(land_frac),minval(land_frac) + +! Are the land fraction from the fractional orography file +! and the 'ceiling' slmsk created from the non-fractional +! logic consistent with each other? + + do j = 1, jdim + do i = 1, idim + if (nint(slmsk(i,j)) == 1) then + if(ceiling(land_frac(i,j)) /= 1.0_8) then + print*,'bad point 1', i,j,slmsk(i,j),ceiling(land_frac(i,j)) + stop + endif + endif + if (ceiling(land_frac(i,j)) == 1.0_8) then + if (nint(slmsk(i,j)) /= 1) then + print*,'bad point 2', i,j,slmsk(i,j),ceiling(land_frac(i,j)) + stop + endif + endif + enddo + enddo + +! Check data. + + allocate(dummy_frac(idim,jdim)) + allocate(dummy_ceil(idim,jdim)) + + error=nf90_open(trim(file_frac),nf90_nowrite,ncid_frac) + call netcdf_err(error, 'opening file_frac' ) + + do var = 1, num_var + + print*,'CHECK FIELD ', trim(varname(var)) + + error=nf90_inq_varid(ncid_frac, varname(var), varid_frac) + call netcdf_err(error, 'reading frac id' ) + error=nf90_get_var(ncid_frac,varid_frac,dummy_frac) + call netcdf_err(error, 'reading frac field' ) + + print*,'frac field ',maxval(dummy_frac),minval(dummy_frac) + + if (trim(varname(var)) == 'tsfcl') varname(var) = 'tsea' + if (trim(varname(var)) == 'zorll') varname(var) = 'zorl' + error=nf90_inq_varid(ncid_ceil, varname(var), varid_ceil) + call netcdf_err(error, 'reading ceil id' ) + error=nf90_get_var(ncid_ceil,varid_ceil,dummy_ceil) + call netcdf_err(error, 'reading ceil field' ) + + print*,'ceil field ',maxval(dummy_ceil),minval(dummy_ceil) + + do j = 1, jdim + do i = 1, idim + + if (nint(slmsk(i,j)) == 1) then + if (dummy_ceil(i,j) /= dummy_frac(i,j)) then + print*,'bad pt ',i,j,dummy_ceil(i,j),dummy_frac(i,j) + stop + endif + endif + + enddo + enddo + + enddo + + allocate(dummy_frac3d(idim,jdim,4)) + allocate(dummy_ceil3d(idim,jdim,4)) + + do var = 1, num_var3d + + print*,'CHECK FIELD ', trim(varname3d(var)) + + error=nf90_inq_varid(ncid_frac, varname3d(var), varid_frac) + call netcdf_err(error, 'reading frac id' ) + error=nf90_get_var(ncid_frac,varid_frac,dummy_frac3d) + call netcdf_err(error, 'reading frac field' ) + + error=nf90_inq_varid(ncid_ceil, varname3d(var), varid_ceil) + call netcdf_err(error, 'reading ceil id' ) + error=nf90_get_var(ncid_ceil,varid_ceil,dummy_ceil3d) + call netcdf_err(error, 'reading ceil field' ) + + do n = 1, 4 + + print*,'frac field level ',n,maxval(dummy_frac3d(:,:,n)),minval(dummy_frac3d(:,:,n)) + print*,'ceil field level ',n,maxval(dummy_ceil3d(:,:,n)),minval(dummy_ceil3d(:,:,n)) + + do j = 1, jdim + do i = 1, idim + + if (nint(slmsk(i,j)) == 1) then + if (dummy_ceil3d(i,j,n) /= dummy_frac3d(i,j,n)) then + print*,'bad pt ',i,j,n,dummy_ceil3d(i,j,n),dummy_frac3d(i,j,n) + endif + endif + + enddo + enddo + + enddo + + enddo + + print*,'DONE' + + end program check + + subroutine netcdf_err( err, string ) + + use netcdf + + implicit none + integer, intent(in) :: err + character(len=*), intent(in) :: string + character(len=256) :: errmsg + integer :: iret + + if( err.EQ.NF90_NOERR )return + errmsg = NF90_STRERROR(err) + print*,'' + print*,'FATAL ERROR: ', trim(string), ': ', trim(errmsg) + print*,'STOP.' + stop 6 + + return + end subroutine netcdf_err From d9f6d96da454f4e174f69f1dd25be66ab897175c Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 14 Apr 2022 20:41:30 +0000 Subject: [PATCH 028/107] Fix bug in setting of snow-free albedo at points with some land (fractional case). Fixes #123 --- sorc/chgres_cube.fd/surface.F90 | 88 +++++++++++++++++---------------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index ffb58a599..244080864 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2302,7 +2302,8 @@ subroutine qc_check use program_setup, only : fract_grid - use model_grid, only : landmask_target_grid + use model_grid, only : landmask_target_grid, & + seamask_target_grid use static_data, only : alvsf_target_grid, & alvwf_target_grid, & @@ -2323,6 +2324,7 @@ subroutine qc_check integer :: clb(2), cub(2), i, j, rc integer(esmf_kind_i8), pointer :: landmask_ptr(:,:) + integer(esmf_kind_i8), pointer :: seamask_ptr(:,:) real(esmf_kind_r8), pointer :: data_ptr(:,:) real(esmf_kind_r8), pointer :: data3d_ptr(:,:,:) @@ -2343,6 +2345,14 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) + if (fract_grid) then + print*,"- CALL FieldGet FOR TARGET GRID SEA MASK." + call ESMF_FieldGet(seamask_target_grid, & + farrayPtr=seamask_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + endif + print*,"- CALL FieldGet FOR TARGET GRID SEA ICE FRACTION." call ESMF_FieldGet(seaice_fract_target_grid, & farrayPtr=fice_ptr, rc=rc) @@ -2411,19 +2421,16 @@ subroutine qc_check enddo if(fract_grid)then - print*,"- SET TARGET GRID ALVSF_NL AT NON-LAND." - call ESMF_FieldGet(alvsf_nl_target_grid, & - farrayPtr=data_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + print*,"- SET TARGET GRID ALVSF_NL AT NON-LAND." + call ESMF_FieldGet(alvsf_nl_target_grid, & + farrayPtr=data_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - -!cfract Setting to flag value at all non-land - ice and all water. -!cfract for fractional grid, this is where landmask_ptr is 0. - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - enddo - enddo + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (seamask_ptr(i,j) == 1) data_ptr(i,j) = 0.06 ! gfs flag value at any non-land + enddo + enddo endif print*,"- SET TARGET GRID ALVWF AT NON-LAND." @@ -2440,17 +2447,16 @@ subroutine qc_check enddo if(fract_grid)then - print*,"- SET TARGET GRID ALVWF_NL AT NON-LAND." - call ESMF_FieldGet(alvwf_nl_target_grid, & - farrayPtr=data_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + print*,"- SET TARGET GRID ALVWF_NL AT NON-LAND." + call ESMF_FieldGet(alvwf_nl_target_grid, & + farrayPtr=data_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - enddo - enddo + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (seamask_ptr(i,j) == 1) data_ptr(i,j) = 0.06 ! gfs flag value at any non-land + enddo + enddo endif print*,"- SET TARGET GRID ALNSF AT NON-LAND." @@ -2467,17 +2473,16 @@ subroutine qc_check enddo if(fract_grid)then - print*,"- SET TARGET GRID ALNSF_NL AT NON-LAND." - call ESMF_FieldGet(alnsf_nl_target_grid, & + print*,"- SET TARGET GRID ALNSF_NL AT NON-LAND." + call ESMF_FieldGet(alnsf_nl_target_grid, & farrayPtr=data_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - enddo - enddo + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (seamask_ptr(i,j) == 1) data_ptr(i,j) = 0.06 ! gfs flag value at any non-land + enddo + enddo endif print*,"- SET TARGET GRID ALNWF AT NON-LAND." @@ -2494,17 +2499,16 @@ subroutine qc_check enddo if(fract_grid)then - print*,"- SET TARGET GRID ALNWF_NL AT NON-LAND." - call ESMF_FieldGet(alnwf_nl_target_grid, & + print*,"- SET TARGET GRID ALNWF_NL AT NON-LAND." + call ESMF_FieldGet(alnwf_nl_target_grid, & farrayPtr=data_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - enddo - enddo + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (seamask_ptr(i,j) == 1) data_ptr(i,j) = 0.06 ! gfs flag value at any non-land. + enddo + enddo endif print*,"- SET NON-LAND FLAG FOR TARGET GRID FACSF." From d90667626002f08681d2fd91a24afd3747dc115b Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 18 Apr 2022 18:46:29 +0000 Subject: [PATCH 029/107] Baseline another tool to check the 'floor' case of the logic. Fixes #123. --- sorc/CMakeLists.txt | 1 + sorc/chgres_tools2.fd/CMakeLists.txt | 16 ++ sorc/chgres_tools2.fd/check.F90 | 210 +++++++++++++++++++++++++++ 3 files changed, 227 insertions(+) create mode 100644 sorc/chgres_tools2.fd/CMakeLists.txt create mode 100644 sorc/chgres_tools2.fd/check.F90 diff --git a/sorc/CMakeLists.txt b/sorc/CMakeLists.txt index a41b1e903..f808a7840 100644 --- a/sorc/CMakeLists.txt +++ b/sorc/CMakeLists.txt @@ -14,6 +14,7 @@ add_subdirectory(fre-nctools.fd) add_subdirectory(grid_tools.fd) add_subdirectory(chgres_cube.fd) add_subdirectory(chgres_tools.fd) +add_subdirectory(chgres_tools2.fd) add_subdirectory(orog_mask_tools.fd) add_subdirectory(sfc_climo_gen.fd) add_subdirectory(vcoord_gen.fd) diff --git a/sorc/chgres_tools2.fd/CMakeLists.txt b/sorc/chgres_tools2.fd/CMakeLists.txt new file mode 100644 index 000000000..00299bfa1 --- /dev/null +++ b/sorc/chgres_tools2.fd/CMakeLists.txt @@ -0,0 +1,16 @@ +set(fortran_src + check.F90) + +if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8") +endif() + +set(exe_name chgres_check2) +add_executable(${exe_name} ${fortran_src}) +target_link_libraries( + ${exe_name} + NetCDF::NetCDF_Fortran) + +install(TARGETS ${exe_name} RUNTIME DESTINATION ${exec_dir}) diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 new file mode 100644 index 000000000..db3d90508 --- /dev/null +++ b/sorc/chgres_tools2.fd/check.F90 @@ -0,0 +1,210 @@ + program check + +! How to use. +! +! 1) Run chgres in fractional grid mode. +! +! 2) Run chgres again using the updated orography files where 'slmsk' is +! updated to be 'floor(land fraction)'. Here chgres is run +! in non-fractional mode. +! +! 3) Compare the fields at land from (2) to the fields with at least +! some non-land from (1). They should match. + + use netcdf + + implicit none + + integer, parameter :: num_var=7 + integer, parameter :: num_var3d=3 + + character(len=150) :: file_floor, file_frac, file_orog_frac + + character(len=15) :: varname(num_var), varname3d(num_var3d) + + integer :: error, id_dim, idim, jdim + integer :: varid, varid_floor, varid_frac, var + integer :: i, j, n, ncid_floor, ncid_orog_frac, ncid_frac + + real*8, allocatable :: slmsk(:,:), land_frac(:,:), dummy_frac(:,:) + real*8, allocatable :: dummy_floor(:,:) + real*8, allocatable :: dummy_frac3d(:,:,:), dummy_floor3d(:,:,:) + + data varname /'alvsf_nl', 'alvwf_nl', 'alnsf_nl', 'alnwf_nl', & + 'f10m', 'ffhh', 'ffmm' / + + data varname3d /'stc', 'slc', 'smc'/ + + file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/out.sfc.tile1.nc" + file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/C96_oro_data.tile1.nc" + file_floor="/gpfs/dell1/stmp/George.Gayno/chgres_floor/out.sfc.tile1.nc" + +! Open the file created using the non-fractional logic, but with +! slmsk modified to be floor of the land fraction. + + error=nf90_open(trim(file_floor),nf90_nowrite,ncid_floor) + call netcdf_err(error, 'opening file_floor' ) + + error=nf90_inq_dimid(ncid_floor, 'xaxis_1', id_dim) + call netcdf_err(error, 'getting xaxis' ) + error=nf90_inquire_dimension(ncid_floor,id_dim,len=idim) + call netcdf_err(error, 'reading xaxis' ) + + error=nf90_inq_dimid(ncid_floor, 'yaxis_1', id_dim) + call netcdf_err(error, 'getting yaxis' ) + error=nf90_inquire_dimension(ncid_floor,id_dim,len=jdim) + call netcdf_err(error, 'reading yaxis' ) + + allocate(slmsk(idim,jdim)) + + error=nf90_inq_varid(ncid_floor,"slmsk",varid) + call netcdf_err(error, 'reading slmsk id' ) + error=nf90_get_var(ncid_floor,varid,slmsk) + call netcdf_err(error, 'reading slmsk' ) + + print*,'slmsk ',maxval(slmsk),minval(slmsk) + +! Open the fractional grid orography file. Read the +! land fraction. + + error=nf90_open(trim(file_orog_frac),nf90_nowrite,ncid_orog_frac) + call netcdf_err(error, 'opening file_orog_frac' ) + + allocate(land_frac(idim,jdim)) + + error=nf90_inq_varid(ncid_orog_frac,"land_frac",varid_frac) + call netcdf_err(error, 'reading land_frac id' ) + error=nf90_get_var(ncid_orog_frac,varid_frac,land_frac) + call netcdf_err(error, 'reading land_frac' ) + + print*,'land_frac ',maxval(land_frac),minval(land_frac) + +! Are the land fraction from the fractional orography file +! and the 'floor' slmsk created from the non-fractional +! logic consistent with each other? + + do j = 1, jdim + do i = 1, idim + if (nint(slmsk(i,j)) == 0) then + if(floor(land_frac(i,j)) /= 0.0_8) then + print*,'bad mask point 1', i,j,slmsk(i,j),floor(land_frac(i,j)) + stop + endif + endif + if (floor(land_frac(i,j)) == 0.0_8) then + if (nint(slmsk(i,j)) /= 0) then + print*,'bad mask point 2', i,j,slmsk(i,j),floor(land_frac(i,j)) + stop + endif + endif + enddo + enddo + +! Check data. + + allocate(dummy_frac(idim,jdim)) + allocate(dummy_floor(idim,jdim)) + + error=nf90_open(trim(file_frac),nf90_nowrite,ncid_frac) + call netcdf_err(error, 'opening file_frac' ) + + do var = 1, num_var + + print*,'CHECK FIELD ', trim(varname(var)) + + error=nf90_inq_varid(ncid_frac, varname(var), varid_frac) + call netcdf_err(error, 'reading frac id' ) + error=nf90_get_var(ncid_frac,varid_frac,dummy_frac) + call netcdf_err(error, 'reading frac field' ) + + print*,'frac field ',maxval(dummy_frac),minval(dummy_frac) + + if (trim(varname(var)) == 'alvsf_nl') varname(var) = 'alvsf' + if (trim(varname(var)) == 'alvwf_nl') varname(var) = 'alvwf' + if (trim(varname(var)) == 'alnsf_nl') varname(var) = 'alnsf' + if (trim(varname(var)) == 'alnwf_nl') varname(var) = 'alnwf' + error=nf90_inq_varid(ncid_floor, varname(var), varid_floor) + call netcdf_err(error, 'reading floor id' ) + error=nf90_get_var(ncid_floor,varid_floor,dummy_floor) + call netcdf_err(error, 'reading floor field' ) + + print*,'floor field ',maxval(dummy_floor),minval(dummy_floor) + + do j = 1, jdim + do i = 1, idim + + if (nint(slmsk(i,j)) == 0) then + if (dummy_floor(i,j) /= dummy_frac(i,j)) then + print*,'bad pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) + stop + endif + endif + + enddo + enddo + + enddo + + stop + + allocate(dummy_frac3d(idim,jdim,4)) + allocate(dummy_floor3d(idim,jdim,4)) + + do var = 1, num_var3d + + print*,'CHECK FIELD ', trim(varname3d(var)) + + error=nf90_inq_varid(ncid_frac, varname3d(var), varid_frac) + call netcdf_err(error, 'reading frac id' ) + error=nf90_get_var(ncid_frac,varid_frac,dummy_frac3d) + call netcdf_err(error, 'reading frac field' ) + + error=nf90_inq_varid(ncid_floor, varname3d(var), varid_floor) + call netcdf_err(error, 'reading floor id' ) + error=nf90_get_var(ncid_floor,varid_floor,dummy_floor3d) + call netcdf_err(error, 'reading floor field' ) + + do n = 1, 4 + + print*,'frac field level ',n,maxval(dummy_frac3d(:,:,n)),minval(dummy_frac3d(:,:,n)) + print*,'floor field level ',n,maxval(dummy_floor3d(:,:,n)),minval(dummy_floor3d(:,:,n)) + + do j = 1, jdim + do i = 1, idim + + if (nint(slmsk(i,j)) == 1) then + if (dummy_floor3d(i,j,n) /= dummy_frac3d(i,j,n)) then + print*,'bad pt ',i,j,n,dummy_floor3d(i,j,n),dummy_frac3d(i,j,n) + endif + endif + + enddo + enddo + + enddo + + enddo + + print*,'DONE' + + end program check + + subroutine netcdf_err( err, string ) + + use netcdf + + implicit none + integer, intent(in) :: err + character(len=*), intent(in) :: string + character(len=256) :: errmsg + integer :: iret + + if( err.EQ.NF90_NOERR )return + errmsg = NF90_STRERROR(err) + print*,'' + print*,'FATAL ERROR: ', trim(string), ': ', trim(errmsg) + print*,'STOP.' + stop 6 + + return + end subroutine netcdf_err From 1b54b51b9b93241a8217fc1640daa9427464d5d3 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 18 Apr 2022 20:03:13 +0000 Subject: [PATCH 030/107] Add check of ice points to chgres_tools2.fd. Add loop over each tile. Fixes #123. --- sorc/chgres_tools2.fd/check.F90 | 38 ++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 index db3d90508..7c5b77c42 100644 --- a/sorc/chgres_tools2.fd/check.F90 +++ b/sorc/chgres_tools2.fd/check.F90 @@ -21,8 +21,10 @@ program check character(len=150) :: file_floor, file_frac, file_orog_frac character(len=15) :: varname(num_var), varname3d(num_var3d) + character(len=16) :: the_files(6) + character(len=21) :: oro_files(6) - integer :: error, id_dim, idim, jdim + integer :: error, id_dim, idim, jdim, tiles integer :: varid, varid_floor, varid_frac, var integer :: i, j, n, ncid_floor, ncid_orog_frac, ncid_frac @@ -35,9 +37,17 @@ program check data varname3d /'stc', 'slc', 'smc'/ - file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/out.sfc.tile1.nc" - file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/C96_oro_data.tile1.nc" - file_floor="/gpfs/dell1/stmp/George.Gayno/chgres_floor/out.sfc.tile1.nc" + data the_files /'out.sfc.tile1.nc', 'out.sfc.tile2.nc', 'out.sfc.tile3.nc', & + 'out.sfc.tile4.nc', 'out.sfc.tile5.nc', 'out.sfc.tile6.nc'/ + + data oro_files /'C96_oro_data.tile1.nc', 'C96_oro_data.tile2.nc', 'C96_oro_data.tile3.nc', & + 'C96_oro_data.tile4.nc', 'C96_oro_data.tile5.nc', 'C96_oro_data.tile6.nc' / + + do tiles = 2, 2 + + file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) + file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" // oro_files(tiles) + file_floor="/gpfs/dell1/stmp/George.Gayno/chgres_floor/" // the_files(tiles) ! Open the file created using the non-fractional logic, but with ! slmsk modified to be floor of the land fraction. @@ -55,7 +65,7 @@ program check error=nf90_inquire_dimension(ncid_floor,id_dim,len=jdim) call netcdf_err(error, 'reading yaxis' ) - allocate(slmsk(idim,jdim)) + if (.not. allocated(slmsk)) allocate(slmsk(idim,jdim)) error=nf90_inq_varid(ncid_floor,"slmsk",varid) call netcdf_err(error, 'reading slmsk id' ) @@ -70,7 +80,7 @@ program check error=nf90_open(trim(file_orog_frac),nf90_nowrite,ncid_orog_frac) call netcdf_err(error, 'opening file_orog_frac' ) - allocate(land_frac(idim,jdim)) + if (.not. allocated(land_frac)) allocate(land_frac(idim,jdim)) error=nf90_inq_varid(ncid_orog_frac,"land_frac",varid_frac) call netcdf_err(error, 'reading land_frac id' ) @@ -85,14 +95,14 @@ program check do j = 1, jdim do i = 1, idim - if (nint(slmsk(i,j)) == 0) then + if (nint(slmsk(i,j)) == 0 .or. nint(slmsk(i,j)) == 2) then if(floor(land_frac(i,j)) /= 0.0_8) then print*,'bad mask point 1', i,j,slmsk(i,j),floor(land_frac(i,j)) stop endif endif if (floor(land_frac(i,j)) == 0.0_8) then - if (nint(slmsk(i,j)) /= 0) then + if (nint(slmsk(i,j)) == 1) then print*,'bad mask point 2', i,j,slmsk(i,j),floor(land_frac(i,j)) stop endif @@ -133,7 +143,7 @@ program check do j = 1, jdim do i = 1, idim - if (nint(slmsk(i,j)) == 0) then + if (nint(slmsk(i,j)) == 0 .or. nint(slmsk(i,j)) == 2) then if (dummy_floor(i,j) /= dummy_frac(i,j)) then print*,'bad pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) stop @@ -145,7 +155,7 @@ program check enddo - stop + goto 33 allocate(dummy_frac3d(idim,jdim,4)) allocate(dummy_floor3d(idim,jdim,4)) @@ -185,6 +195,14 @@ program check enddo + 33 continue + + error=nf90_close(ncid_floor) + error=nf90_close(ncid_orog_frac) + error=nf90_close(ncid_frac) + + enddo + print*,'DONE' end program check From 89e66d7e8a45f09dd16f73105c9fd8739badec8a Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 18 Apr 2022 21:09:40 +0000 Subject: [PATCH 031/107] Add more variables to the ./chgres_tools2 check tool. Fixes #123. --- sorc/chgres_tools2.fd/check.F90 | 57 ++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 index 7c5b77c42..c7287885a 100644 --- a/sorc/chgres_tools2.fd/check.F90 +++ b/sorc/chgres_tools2.fd/check.F90 @@ -15,8 +15,8 @@ program check implicit none - integer, parameter :: num_var=7 - integer, parameter :: num_var3d=3 + integer, parameter :: num_var=15 + integer, parameter :: num_var3d=1 character(len=150) :: file_floor, file_frac, file_orog_frac @@ -33,9 +33,11 @@ program check real*8, allocatable :: dummy_frac3d(:,:,:), dummy_floor3d(:,:,:) data varname /'alvsf_nl', 'alvwf_nl', 'alnsf_nl', 'alnwf_nl', & - 'f10m', 'ffhh', 'ffmm' / + 'f10m', 'ffhh', 'ffmm', 'fice', 'hice', & + 'q2m', 'sheleg_ice', 'snwdph_ice', 'srflag', & + 't2m', 'tg3_ice' / - data varname3d /'stc', 'slc', 'smc'/ + data varname3d /'stc_ice'/ data the_files /'out.sfc.tile1.nc', 'out.sfc.tile2.nc', 'out.sfc.tile3.nc', & 'out.sfc.tile4.nc', 'out.sfc.tile5.nc', 'out.sfc.tile6.nc'/ @@ -133,6 +135,9 @@ program check if (trim(varname(var)) == 'alvwf_nl') varname(var) = 'alvwf' if (trim(varname(var)) == 'alnsf_nl') varname(var) = 'alnsf' if (trim(varname(var)) == 'alnwf_nl') varname(var) = 'alnwf' + if (trim(varname(var)) == 'sheleg_ice') varname(var) = 'sheleg' + if (trim(varname(var)) == 'snwdph_ice') varname(var) = 'snwdph' + if (trim(varname(var)) == 'tg3_ice') varname(var) = 'tg3' error=nf90_inq_varid(ncid_floor, varname(var), varid_floor) call netcdf_err(error, 'reading floor id' ) error=nf90_get_var(ncid_floor,varid_floor,dummy_floor) @@ -140,25 +145,34 @@ program check print*,'floor field ',maxval(dummy_floor),minval(dummy_floor) - do j = 1, jdim - do i = 1, idim - - if (nint(slmsk(i,j)) == 0 .or. nint(slmsk(i,j)) == 2) then - if (dummy_floor(i,j) /= dummy_frac(i,j)) then - print*,'bad pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) - stop + if (trim(varname(var)) == 'tg3') then + do j = 1, jdim + do i = 1, idim + if (nint(slmsk(i,j)) == 2) then + if (dummy_floor(i,j) /= dummy_frac(i,j)) then + print*,'bad pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) + stop + endif endif - endif - - enddo - enddo + enddo + enddo + else + do j = 1, jdim + do i = 1, idim + if (nint(slmsk(i,j)) == 0 .or. nint(slmsk(i,j)) == 2) then + if (dummy_floor(i,j) /= dummy_frac(i,j)) then + print*,'bad pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) + stop + endif + endif + enddo + enddo + endif enddo - goto 33 - - allocate(dummy_frac3d(idim,jdim,4)) - allocate(dummy_floor3d(idim,jdim,4)) + if(.not.allocated(dummy_frac3d)) allocate(dummy_frac3d(idim,jdim,4)) + if(.not.allocated(dummy_floor3d)) allocate(dummy_floor3d(idim,jdim,4)) do var = 1, num_var3d @@ -169,6 +183,7 @@ program check error=nf90_get_var(ncid_frac,varid_frac,dummy_frac3d) call netcdf_err(error, 'reading frac field' ) + if (trim(varname3d(var)) == 'stc_ice') varname3d(var) = 'stc' error=nf90_inq_varid(ncid_floor, varname3d(var), varid_floor) call netcdf_err(error, 'reading floor id' ) error=nf90_get_var(ncid_floor,varid_floor,dummy_floor3d) @@ -182,7 +197,7 @@ program check do j = 1, jdim do i = 1, idim - if (nint(slmsk(i,j)) == 1) then + if (nint(slmsk(i,j)) == 2) then if (dummy_floor3d(i,j,n) /= dummy_frac3d(i,j,n)) then print*,'bad pt ',i,j,n,dummy_floor3d(i,j,n),dummy_frac3d(i,j,n) endif @@ -195,8 +210,6 @@ program check enddo - 33 continue - error=nf90_close(ncid_floor) error=nf90_close(ncid_orog_frac) error=nf90_close(ncid_frac) From 62275c5845ed6a448fe85c802ac63651a7e5f917 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 26 Apr 2022 13:03:49 +0000 Subject: [PATCH 032/107] Fix bug in chgres_tools2.fd/check.F90 Fixes #123. --- sorc/chgres_tools2.fd/check.F90 | 52 ++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 index c7287885a..3442f6ee8 100644 --- a/sorc/chgres_tools2.fd/check.F90 +++ b/sorc/chgres_tools2.fd/check.F90 @@ -20,7 +20,8 @@ program check character(len=150) :: file_floor, file_frac, file_orog_frac - character(len=15) :: varname(num_var), varname3d(num_var3d) + character(len=15) :: varname_frac(num_var), varname3d_frac(num_var3d) + character(len=15) :: varname_floor(num_var), varname3d_floor(num_var3d) character(len=16) :: the_files(6) character(len=21) :: oro_files(6) @@ -32,12 +33,19 @@ program check real*8, allocatable :: dummy_floor(:,:) real*8, allocatable :: dummy_frac3d(:,:,:), dummy_floor3d(:,:,:) - data varname /'alvsf_nl', 'alvwf_nl', 'alnsf_nl', 'alnwf_nl', & + data varname_frac /'alvsf_nl', 'alvwf_nl', 'alnsf_nl', 'alnwf_nl', & 'f10m', 'ffhh', 'ffmm', 'fice', 'hice', & 'q2m', 'sheleg_ice', 'snwdph_ice', 'srflag', & 't2m', 'tg3_ice' / - data varname3d /'stc_ice'/ + data varname_floor /'alvsf', 'alvwf', 'alnsf', 'alnwf', & + 'f10m', 'ffhh', 'ffmm', 'fice', 'hice', & + 'q2m', 'sheleg', 'snwdph', 'srflag', & + 't2m', 'tg3' / + + data varname3d_frac /'stc_ice'/ + + data varname3d_floor /'stc'/ data the_files /'out.sfc.tile1.nc', 'out.sfc.tile2.nc', 'out.sfc.tile3.nc', & 'out.sfc.tile4.nc', 'out.sfc.tile5.nc', 'out.sfc.tile6.nc'/ @@ -45,7 +53,7 @@ program check data oro_files /'C96_oro_data.tile1.nc', 'C96_oro_data.tile2.nc', 'C96_oro_data.tile3.nc', & 'C96_oro_data.tile4.nc', 'C96_oro_data.tile5.nc', 'C96_oro_data.tile6.nc' / - do tiles = 2, 2 + do tiles = 1, 2 file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" // oro_files(tiles) @@ -54,6 +62,7 @@ program check ! Open the file created using the non-fractional logic, but with ! slmsk modified to be floor of the land fraction. + print*,'- OPEN FILE ',trim(file_floor) error=nf90_open(trim(file_floor),nf90_nowrite,ncid_floor) call netcdf_err(error, 'opening file_floor' ) @@ -79,6 +88,7 @@ program check ! Open the fractional grid orography file. Read the ! land fraction. + print*,'- OPEN FILE ',trim(file_orog_frac) error=nf90_open(trim(file_orog_frac),nf90_nowrite,ncid_orog_frac) call netcdf_err(error, 'opening file_orog_frac' ) @@ -114,43 +124,39 @@ program check ! Check data. - allocate(dummy_frac(idim,jdim)) - allocate(dummy_floor(idim,jdim)) + if(.not.allocated(dummy_frac)) allocate(dummy_frac(idim,jdim)) + if(.not.allocated(dummy_floor)) allocate(dummy_floor(idim,jdim)) + print*,'- OPEN FILE ',trim(file_frac) error=nf90_open(trim(file_frac),nf90_nowrite,ncid_frac) call netcdf_err(error, 'opening file_frac' ) + print*,'process tile number ',tiles + do var = 1, num_var - print*,'CHECK FIELD ', trim(varname(var)) + print*,'CHECK FIELD ', trim(varname_frac(var)) - error=nf90_inq_varid(ncid_frac, varname(var), varid_frac) + error=nf90_inq_varid(ncid_frac, varname_frac(var), varid_frac) call netcdf_err(error, 'reading frac id' ) error=nf90_get_var(ncid_frac,varid_frac,dummy_frac) call netcdf_err(error, 'reading frac field' ) print*,'frac field ',maxval(dummy_frac),minval(dummy_frac) - if (trim(varname(var)) == 'alvsf_nl') varname(var) = 'alvsf' - if (trim(varname(var)) == 'alvwf_nl') varname(var) = 'alvwf' - if (trim(varname(var)) == 'alnsf_nl') varname(var) = 'alnsf' - if (trim(varname(var)) == 'alnwf_nl') varname(var) = 'alnwf' - if (trim(varname(var)) == 'sheleg_ice') varname(var) = 'sheleg' - if (trim(varname(var)) == 'snwdph_ice') varname(var) = 'snwdph' - if (trim(varname(var)) == 'tg3_ice') varname(var) = 'tg3' - error=nf90_inq_varid(ncid_floor, varname(var), varid_floor) + error=nf90_inq_varid(ncid_floor, varname_floor(var), varid_floor) call netcdf_err(error, 'reading floor id' ) error=nf90_get_var(ncid_floor,varid_floor,dummy_floor) call netcdf_err(error, 'reading floor field' ) print*,'floor field ',maxval(dummy_floor),minval(dummy_floor) - if (trim(varname(var)) == 'tg3') then + if (trim(varname_floor(var)) == 'tg3') then do j = 1, jdim do i = 1, idim if (nint(slmsk(i,j)) == 2) then if (dummy_floor(i,j) /= dummy_frac(i,j)) then - print*,'bad pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) + print*,'bad tg3 pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) stop endif endif @@ -176,15 +182,14 @@ program check do var = 1, num_var3d - print*,'CHECK FIELD ', trim(varname3d(var)) + print*,'CHECK FIELD ', trim(varname3d_frac(var)) - error=nf90_inq_varid(ncid_frac, varname3d(var), varid_frac) + error=nf90_inq_varid(ncid_frac, varname3d_frac(var), varid_frac) call netcdf_err(error, 'reading frac id' ) error=nf90_get_var(ncid_frac,varid_frac,dummy_frac3d) call netcdf_err(error, 'reading frac field' ) - if (trim(varname3d(var)) == 'stc_ice') varname3d(var) = 'stc' - error=nf90_inq_varid(ncid_floor, varname3d(var), varid_floor) + error=nf90_inq_varid(ncid_floor, varname3d_floor(var), varid_floor) call netcdf_err(error, 'reading floor id' ) error=nf90_get_var(ncid_floor,varid_floor,dummy_floor3d) call netcdf_err(error, 'reading floor field' ) @@ -199,7 +204,8 @@ program check if (nint(slmsk(i,j)) == 2) then if (dummy_floor3d(i,j,n) /= dummy_frac3d(i,j,n)) then - print*,'bad pt ',i,j,n,dummy_floor3d(i,j,n),dummy_frac3d(i,j,n) + print*,'bad 3d pt ',i,j,n,dummy_floor3d(i,j,n),dummy_frac3d(i,j,n) + stop endif endif From 31bceb53643ce71b6c583454104f46ace3fd2222 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 26 Apr 2022 14:14:13 +0000 Subject: [PATCH 033/107] Update ./chgres_tools.fd/check.F90 to loop over multiple tiles. Fixes #123. --- sorc/chgres_tools.fd/check.F90 | 63 +++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/sorc/chgres_tools.fd/check.F90 b/sorc/chgres_tools.fd/check.F90 index 347aa00db..119c3245a 100644 --- a/sorc/chgres_tools.fd/check.F90 +++ b/sorc/chgres_tools.fd/check.F90 @@ -20,9 +20,12 @@ program check character(len=150) :: file_ceiling, file_frac, file_orog_frac - character(len=15) :: varname(num_var), varname3d(num_var3d) + character(len=15) :: varname_frac(num_var), varname3d(num_var3d) + character(len=15) :: varname_ceil(num_var) + character(len=21) :: oro_files(6) + character(len=16) :: the_files(6) - integer :: error, id_dim, idim, jdim + integer :: error, id_dim, idim, jdim, tiles integer :: varid, varid_ceil, varid_frac, var integer :: i, j, n, ncid_ceil, ncid_orog_frac, ncid_frac @@ -30,22 +33,38 @@ program check real*8, allocatable :: dummy_ceil(:,:) real*8, allocatable :: dummy_frac3d(:,:,:), dummy_ceil3d(:,:,:) - data varname /'alvsf', 'alvwf', 'alnsf', 'alnwf', 'canopy', & + data varname_frac /'alvsf', 'alvwf', 'alnsf', 'alnwf', 'canopy', & 'f10m' , 'facsf', 'facwf', 'ffhh' , 'ffmm', & 'q2m' , 'shdmax','shdmin', 'sheleg', 'slope', & 'snoalb', 'snwdph', 'srflag','stype', 't2m', & 'tg3', 'tprcp', 'tsfcl', 'uustar', 'vfrac', & 'vtype', 'zorll' / + data varname_ceil /'alvsf', 'alvwf', 'alnsf', 'alnwf', 'canopy', & + 'f10m' , 'facsf', 'facwf', 'ffhh' , 'ffmm', & + 'q2m' , 'shdmax','shdmin', 'sheleg', 'slope', & + 'snoalb', 'snwdph', 'srflag','stype', 't2m', & + 'tg3', 'tprcp', 'tsea', 'uustar', 'vfrac', & + 'vtype', 'zorl' / + + data the_files /'out.sfc.tile1.nc', 'out.sfc.tile2.nc', 'out.sfc.tile3.nc', & + 'out.sfc.tile4.nc', 'out.sfc.tile5.nc', 'out.sfc.tile6.nc'/ + + data oro_files /'C96_oro_data.tile1.nc', 'C96_oro_data.tile2.nc', 'C96_oro_data.tile3.nc', & + 'C96_oro_data.tile4.nc', 'C96_oro_data.tile5.nc', 'C96_oro_data.tile6.nc' / + data varname3d /'stc', 'slc', 'smc'/ - file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/out.sfc.tile1.nc" - file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/C96_oro_data.tile1.nc" - file_ceiling="/gpfs/dell1/stmp/George.Gayno/chgres_ceiling/out.sfc.tile1.nc" + TILE : do tiles = 1, 6 + + file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) + file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" // oro_files(tiles) + file_ceiling="/gpfs/dell1/stmp/George.Gayno/chgres_ceiling/" // the_files(tiles) ! Open the file created using the non-fractional logic, but with ! slmsk modified to be ceiling of the land fraction. + print*,"- OPEN FILE ", trim(file_ceiling) error=nf90_open(trim(file_ceiling),nf90_nowrite,ncid_ceil) call netcdf_err(error, 'opening file_ceiling' ) @@ -59,7 +78,7 @@ program check error=nf90_inquire_dimension(ncid_ceil,id_dim,len=jdim) call netcdf_err(error, 'reading yaxis' ) - allocate(slmsk(idim,jdim)) + if(.not.allocated(slmsk)) allocate(slmsk(idim,jdim)) error=nf90_inq_varid(ncid_ceil,"slmsk",varid) call netcdf_err(error, 'reading slmsk id' ) @@ -71,10 +90,11 @@ program check ! Open the fractional grid orography file. Read the ! land fraction. + print*,"- OPEN FILE ", trim(file_orog_frac) error=nf90_open(trim(file_orog_frac),nf90_nowrite,ncid_orog_frac) call netcdf_err(error, 'opening file_orog_frac' ) - allocate(land_frac(idim,jdim)) + if(.not.allocated(land_frac)) allocate(land_frac(idim,jdim)) error=nf90_inq_varid(ncid_orog_frac,"land_frac",varid_frac) call netcdf_err(error, 'reading land_frac id' ) @@ -91,13 +111,13 @@ program check do i = 1, idim if (nint(slmsk(i,j)) == 1) then if(ceiling(land_frac(i,j)) /= 1.0_8) then - print*,'bad point 1', i,j,slmsk(i,j),ceiling(land_frac(i,j)) + print*,'bad mask point 1', i,j,slmsk(i,j),ceiling(land_frac(i,j)) stop endif endif if (ceiling(land_frac(i,j)) == 1.0_8) then if (nint(slmsk(i,j)) /= 1) then - print*,'bad point 2', i,j,slmsk(i,j),ceiling(land_frac(i,j)) + print*,'bad mask point 2', i,j,slmsk(i,j),ceiling(land_frac(i,j)) stop endif endif @@ -106,26 +126,26 @@ program check ! Check data. - allocate(dummy_frac(idim,jdim)) - allocate(dummy_ceil(idim,jdim)) + if(.not.allocated(dummy_frac)) allocate(dummy_frac(idim,jdim)) + if(.not.allocated(dummy_ceil)) allocate(dummy_ceil(idim,jdim)) + print*,"- OPEN FILE ", trim(file_frac) error=nf90_open(trim(file_frac),nf90_nowrite,ncid_frac) call netcdf_err(error, 'opening file_frac' ) do var = 1, num_var - print*,'CHECK FIELD ', trim(varname(var)) + print*,'CHECK FIELD ', trim(varname_frac(var)) - error=nf90_inq_varid(ncid_frac, varname(var), varid_frac) + error=nf90_inq_varid(ncid_frac, varname_frac(var), varid_frac) call netcdf_err(error, 'reading frac id' ) error=nf90_get_var(ncid_frac,varid_frac,dummy_frac) call netcdf_err(error, 'reading frac field' ) print*,'frac field ',maxval(dummy_frac),minval(dummy_frac) - if (trim(varname(var)) == 'tsfcl') varname(var) = 'tsea' - if (trim(varname(var)) == 'zorll') varname(var) = 'zorl' - error=nf90_inq_varid(ncid_ceil, varname(var), varid_ceil) + print*,'read variable ',varname_ceil(var) + error=nf90_inq_varid(ncid_ceil, varname_ceil(var), varid_ceil) call netcdf_err(error, 'reading ceil id' ) error=nf90_get_var(ncid_ceil,varid_ceil,dummy_ceil) call netcdf_err(error, 'reading ceil field' ) @@ -147,8 +167,8 @@ program check enddo - allocate(dummy_frac3d(idim,jdim,4)) - allocate(dummy_ceil3d(idim,jdim,4)) + if(.not.allocated(dummy_frac3d)) allocate(dummy_frac3d(idim,jdim,4)) + if(.not.allocated(dummy_ceil3d)) allocate(dummy_ceil3d(idim,jdim,4)) do var = 1, num_var3d @@ -174,7 +194,8 @@ program check if (nint(slmsk(i,j)) == 1) then if (dummy_ceil3d(i,j,n) /= dummy_frac3d(i,j,n)) then - print*,'bad pt ',i,j,n,dummy_ceil3d(i,j,n),dummy_frac3d(i,j,n) + print*,'bad 3d pt ',i,j,n,dummy_ceil3d(i,j,n),dummy_frac3d(i,j,n) + stop endif endif @@ -185,6 +206,8 @@ program check enddo + enddo TILE + print*,'DONE' end program check From a1f6d79f7a7d36ba8782ba483033d27899549dac Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 26 Apr 2022 15:20:18 +0000 Subject: [PATCH 034/107] Add more variables to ./chgres_tools2.fd/check.F90. Fixes #123. --- sorc/chgres_tools2.fd/check.F90 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 index 3442f6ee8..391f7c7f9 100644 --- a/sorc/chgres_tools2.fd/check.F90 +++ b/sorc/chgres_tools2.fd/check.F90 @@ -15,7 +15,7 @@ program check implicit none - integer, parameter :: num_var=15 + integer, parameter :: num_var=19 integer, parameter :: num_var3d=1 character(len=150) :: file_floor, file_frac, file_orog_frac @@ -36,12 +36,14 @@ program check data varname_frac /'alvsf_nl', 'alvwf_nl', 'alnsf_nl', 'alnwf_nl', & 'f10m', 'ffhh', 'ffmm', 'fice', 'hice', & 'q2m', 'sheleg_ice', 'snwdph_ice', 'srflag', & - 't2m', 'tg3_ice' / + 't2m', 'tg3_ice', 'tisfc', 'tprcp', & + 'uustar', 'zorl_ice' / data varname_floor /'alvsf', 'alvwf', 'alnsf', 'alnwf', & 'f10m', 'ffhh', 'ffmm', 'fice', 'hice', & 'q2m', 'sheleg', 'snwdph', 'srflag', & - 't2m', 'tg3' / + 't2m', 'tg3', 'tisfc', 'tprcp', & + 'uustar', 'zorl' / data varname3d_frac /'stc_ice'/ @@ -53,7 +55,7 @@ program check data oro_files /'C96_oro_data.tile1.nc', 'C96_oro_data.tile2.nc', 'C96_oro_data.tile3.nc', & 'C96_oro_data.tile4.nc', 'C96_oro_data.tile5.nc', 'C96_oro_data.tile6.nc' / - do tiles = 1, 2 + do tiles = 3, 3 file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" // oro_files(tiles) @@ -151,7 +153,9 @@ program check print*,'floor field ',maxval(dummy_floor),minval(dummy_floor) - if (trim(varname_floor(var)) == 'tg3') then + if (trim(varname_frac(var)) == 'tg3_ice' .or. & + trim(varname_frac(var)) == 'tisfc' .or. & + trim(varname_frac(var)) == 'zorl_ice') then do j = 1, jdim do i = 1, idim if (nint(slmsk(i,j)) == 2) then From a0344b3a0503af1ebf97171f1c1acdcee7064974 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 26 Apr 2022 19:43:40 +0000 Subject: [PATCH 035/107] Fix bug in setting of mask for water fields search. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index fe940e7fc..6dee378c0 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -1018,8 +1018,8 @@ subroutine interp(localpet) do tile = 1, num_tiles_target_grid - print*,"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile - call ESMF_FieldGather(landmask_target_grid, mask_target_one_tile, rootPet=0, tile=tile, rc=rc) + print*,"- CALL FieldGather FOR TARGET SEAMASK TILE: ", tile + call ESMF_FieldGather(seamask_target_grid, mask_target_one_tile, rootPet=0, tile=tile, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) @@ -1037,7 +1037,7 @@ subroutine interp(localpet) if (localpet == 0) then allocate(water_target_one_tile(i_target,j_target)) water_target_one_tile = 0 - where(mask_target_one_tile == 0) water_target_one_tile = 1 + where(mask_target_one_tile == 1) water_target_one_tile = 1 where(fice_target_one_tile > 0.0) water_target_one_tile = 0 endif From a693a7cc28a20b39f7c27d3dde2686d557fdccfe Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 26 Apr 2022 21:04:12 +0000 Subject: [PATCH 036/107] Add remaining field checks to ./chgres_tools2.fd/check.F90 Fixes #123. --- sorc/chgres_tools2.fd/check.F90 | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 index 391f7c7f9..0627c7f82 100644 --- a/sorc/chgres_tools2.fd/check.F90 +++ b/sorc/chgres_tools2.fd/check.F90 @@ -8,14 +8,14 @@ program check ! updated to be 'floor(land fraction)'. Here chgres is run ! in non-fractional mode. ! -! 3) Compare the fields at land from (2) to the fields with at least -! some non-land from (1). They should match. +! 3) Compare the fields at non-land from (2) to the fields with some +! non-land from (1). They should match. use netcdf implicit none - integer, parameter :: num_var=19 + integer, parameter :: num_var=21 integer, parameter :: num_var3d=1 character(len=150) :: file_floor, file_frac, file_orog_frac @@ -37,13 +37,13 @@ program check 'f10m', 'ffhh', 'ffmm', 'fice', 'hice', & 'q2m', 'sheleg_ice', 'snwdph_ice', 'srflag', & 't2m', 'tg3_ice', 'tisfc', 'tprcp', & - 'uustar', 'zorl_ice' / + 'tsea', 'uustar', 'zorl_ice', 'zorl' / data varname_floor /'alvsf', 'alvwf', 'alnsf', 'alnwf', & 'f10m', 'ffhh', 'ffmm', 'fice', 'hice', & 'q2m', 'sheleg', 'snwdph', 'srflag', & 't2m', 'tg3', 'tisfc', 'tprcp', & - 'uustar', 'zorl' / + 'tsea', 'uustar', 'zorl', 'zorl' / data varname3d_frac /'stc_ice'/ @@ -55,7 +55,7 @@ program check data oro_files /'C96_oro_data.tile1.nc', 'C96_oro_data.tile2.nc', 'C96_oro_data.tile3.nc', & 'C96_oro_data.tile4.nc', 'C96_oro_data.tile5.nc', 'C96_oro_data.tile6.nc' / - do tiles = 3, 3 + do tiles = 1, 6 file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" // oro_files(tiles) @@ -155,7 +155,7 @@ program check if (trim(varname_frac(var)) == 'tg3_ice' .or. & trim(varname_frac(var)) == 'tisfc' .or. & - trim(varname_frac(var)) == 'zorl_ice') then + trim(varname_frac(var)) == 'zorl_ice') then ! check at ice only. do j = 1, jdim do i = 1, idim if (nint(slmsk(i,j)) == 2) then @@ -166,6 +166,18 @@ program check endif enddo enddo + elseif (trim(varname_frac(var)) == 'zorl' .or. & + trim(varname_frac(var)) == 'tsea') then ! check at open water only. + do j = 1, jdim + do i = 1, idim + if (nint(slmsk(i,j)) == 0) then + if (dummy_floor(i,j) /= dummy_frac(i,j)) then + print*,'bad water pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) + stop + endif + endif + enddo + enddo else do j = 1, jdim do i = 1, idim From d52c4279c96b58f92c5c8a7f24fef98db9ae3431 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 27 Apr 2022 14:23:30 +0000 Subject: [PATCH 037/107] Fix diagnostic print statement. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 6dee378c0..d40b032a8 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2524,7 +2524,7 @@ subroutine qc_check enddo enddo - print*,"- SET NON-LAND FLAG FOR TARGET GRID FACSF." + print*,"- SET NON-LAND FLAG FOR TARGET GRID FACWF." call ESMF_FieldGet(facwf_target_grid, & farrayPtr=data_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & From 30f3742e9678ebf53472ef4fa1ffa1426f3e9430 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 27 Apr 2022 19:46:30 +0000 Subject: [PATCH 038/107] Update for nst fields. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 25 +++++++++++++---------- sorc/chgres_tools2.fd/check.F90 | 35 ++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index d40b032a8..f1faa8798 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2771,7 +2771,9 @@ end subroutine qc_check !! @author George Gayno NOAA/EMC subroutine nst_land_fill - use model_grid, only : landmask_target_grid + use model_grid, only : seamask_target_grid + + use program_setup, only : fract_grid implicit none @@ -2788,8 +2790,8 @@ subroutine nst_land_fill type(esmf_field) :: temp_field type(esmf_fieldbundle) :: nst_bundle - print*,"- CALL FieldGet FOR TARGET GRID LANDMASK." - call ESMF_FieldGet(landmask_target_grid, & + print*,"- CALL FieldGet FOR TARGET GRID SEAMASK." + call ESMF_FieldGet(seamask_target_grid, & farrayPtr=mask_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldGet", rc) @@ -2825,12 +2827,15 @@ subroutine nst_land_fill call error_handler("IN FieldGet", rc) !cfract Setting filler value for tref at ice and land points. -!cfract Under fractional grids use seamask_target, where =0 -!cfract is all land. And use fice field for ice. -!cfrac where(seamask_target == 0) .and where (fice > 0) data_ptr=skint_ptr +!cfract Under fractional grids skin t is not currently defined. +!cfract So, set to ice temp. - where(mask_ptr == 1) data_ptr = skint_ptr - where(fice_ptr > 0.0) data_ptr = skint_ptr + where(mask_ptr == 0) data_ptr = skint_ptr + if (fract_grid) then + where(fice_ptr > 0.0) data_ptr = frz_ice + else + where(fice_ptr > 0.0) data_ptr = skint_ptr + endif ! xz @@ -2841,7 +2846,7 @@ subroutine nst_land_fill call error_handler("IN FieldGet", rc) !cfract same as above. - where(mask_ptr == 1) data_ptr = xz_fill + where(mask_ptr == 0) data_ptr = xz_fill where(fice_ptr > 0.0) data_ptr = xz_fill do i = 1,num_nst_fields_minus2 @@ -2855,7 +2860,7 @@ subroutine nst_land_fill call error_handler("IN FieldGet", rc) !cfract same as above. - where(mask_ptr == 1) data_ptr = nst_fill + where(mask_ptr == 0) data_ptr = nst_fill where(fice_ptr > 0.0) data_ptr = nst_fill enddo diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 index 0627c7f82..4b12b33fe 100644 --- a/sorc/chgres_tools2.fd/check.F90 +++ b/sorc/chgres_tools2.fd/check.F90 @@ -15,7 +15,7 @@ program check implicit none - integer, parameter :: num_var=21 + integer, parameter :: num_var=39 integer, parameter :: num_var3d=1 character(len=150) :: file_floor, file_frac, file_orog_frac @@ -37,13 +37,21 @@ program check 'f10m', 'ffhh', 'ffmm', 'fice', 'hice', & 'q2m', 'sheleg_ice', 'snwdph_ice', 'srflag', & 't2m', 'tg3_ice', 'tisfc', 'tprcp', & - 'tsea', 'uustar', 'zorl_ice', 'zorl' / + 'tsea', 'uustar', 'zorl_ice', 'zorl', & + 'c_0', 'c_d', 'd_conv', 'dt_cool', 'ifd', & + 'qrain', 'tref', 'w_0', 'w_d', 'xs', & + 'xt', 'xtts', 'xu', 'xv', 'xz', & + 'xzts', 'z_c', 'zm'/ data varname_floor /'alvsf', 'alvwf', 'alnsf', 'alnwf', & 'f10m', 'ffhh', 'ffmm', 'fice', 'hice', & 'q2m', 'sheleg', 'snwdph', 'srflag', & 't2m', 'tg3', 'tisfc', 'tprcp', & - 'tsea', 'uustar', 'zorl', 'zorl' / + 'tsea', 'uustar', 'zorl', 'zorl', & + 'c_0', 'c_d', 'd_conv', 'dt_cool', 'ifd', & + 'qrain', 'tref', 'w_0', 'w_d', 'xs', & + 'xt', 'xtts', 'xu', 'xv', 'xz', & + 'xzts', 'z_c', 'zm'/ data varname3d_frac /'stc_ice'/ @@ -167,7 +175,24 @@ program check enddo enddo elseif (trim(varname_frac(var)) == 'zorl' .or. & - trim(varname_frac(var)) == 'tsea') then ! check at open water only. + trim(varname_frac(var)) == 'tsea' .or. & + trim(varname_frac(var)) == 'c_0' .or. & + trim(varname_frac(var)) == 'c_d' .or. & + trim(varname_frac(var)) == 'd_conv' .or. & + trim(varname_frac(var)) == 'dt_cool' .or. & + trim(varname_frac(var)) == 'qrain' .or. & + trim(varname_frac(var)) == 'w_0' .or. & + trim(varname_frac(var)) == 'w_d' .or. & + trim(varname_frac(var)) == 'xs' .or. & + trim(varname_frac(var)) == 'xt' .or. & + trim(varname_frac(var)) == 'xtts' .or. & + trim(varname_frac(var)) == 'xu' .or. & + trim(varname_frac(var)) == 'xv' .or. & + trim(varname_frac(var)) == 'xz' .or. & + trim(varname_frac(var)) == 'xzts' .or. & + trim(varname_frac(var)) == 'z_c' .or. & + trim(varname_frac(var)) == 'zm' .or. & + trim(varname_frac(var)) == 'tref') then ! check at open water only. do j = 1, jdim do i = 1, idim if (nint(slmsk(i,j)) == 0) then @@ -178,7 +203,7 @@ program check endif enddo enddo - else + else ! Check at ice and open water. do j = 1, jdim do i = 1, idim if (nint(slmsk(i,j)) == 0 .or. nint(slmsk(i,j)) == 2) then From e74d1437330864f480dc11ce68ce6e2b99ff21cb Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 27 Apr 2022 20:16:35 +0000 Subject: [PATCH 039/107] Update ./ftst_surface_nst_landfill.F90 unit test for fractional grid. Fixes #123. --- tests/chgres_cube/ftst_surface_nst_landfill.F90 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/chgres_cube/ftst_surface_nst_landfill.F90 b/tests/chgres_cube/ftst_surface_nst_landfill.F90 index 00d801478..d8d525e7b 100644 --- a/tests/chgres_cube/ftst_surface_nst_landfill.F90 +++ b/tests/chgres_cube/ftst_surface_nst_landfill.F90 @@ -9,11 +9,13 @@ program surface_nst_landfill use model_grid, only : i_target, j_target, & target_grid, num_tiles_target_grid, & - landmask_target_grid + seamask_target_grid use surface, only : nst_land_fill, & create_nst_esmf_fields + use program_setup, only : fract_grid + use surface_target_data, only : skin_temp_target_grid, & c_d_target_grid, & c_0_target_grid, & @@ -79,6 +81,8 @@ program surface_nst_landfill !---------------- Setup Target Grid & Coordinates -------------------! !--------------------------------------------------------------------! + fract_grid = .false. + i_target = IPTS_TARGET j_target = JPTS_TARGET @@ -91,10 +95,10 @@ program surface_nst_landfill if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN GridAddCoord", rc) - landmask_target_grid = ESMF_FieldCreate(target_grid, & + seamask_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_I8, & staggerloc=ESMF_STAGGERLOC_CENTER, & - name="target_grid_landmask", & + name="target_grid_seamask", & rc=rc) skin_temp_target_grid = ESMF_FieldCreate(target_grid, & @@ -111,12 +115,12 @@ program surface_nst_landfill allocate(tref_correct(i_target,j_target)) allocate(xz_correct(i_target,j_target)) - mask = reshape((/0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0/),(/i_target,j_target/)) + mask = reshape((/1,1,1,1,1,0,0,1,1,0,0,1,1,1,1,1/),(/i_target,j_target/)) skin_temp = reshape((/280., 280., 280., 280., & 280., 290., 290., 280., & 280., 290., 290., 280., & 280., 280., 280., 280./),(/i_target,j_target/)) - call ESMF_FieldScatter(landmask_target_grid, mask, rootpet=0, rc=rc) + call ESMF_FieldScatter(seamask_target_grid, mask, rootpet=0, rc=rc) call ESMF_FieldScatter(skin_temp_target_grid, skin_temp, rootpet=0, rc=rc) deallocate(mask, skin_temp) @@ -215,7 +219,7 @@ program surface_nst_landfill deallocate(tmp_array_2d,nst_field_correct,tref_correct,xz_correct) - call ESMF_FieldDestroy(landmask_target_grid,rc=rc) + call ESMF_FieldDestroy(seamask_target_grid,rc=rc) call ESMF_FieldDestroy(skin_temp_target_grid,rc=rc) call cleanup_target_nst_data call ESMF_GridDestroy(target_grid,rc=rc) From 56bf230bed6256b51d968de71ed5cf7c874be1a4 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 27 Apr 2022 20:51:19 +0000 Subject: [PATCH 040/107] Update unit tests for new logic. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 2 +- sorc/chgres_tools.fd/check.F90 | 3 ++- sorc/chgres_tools2.fd/check.F90 | 3 ++- .../chgres_cube/ftst_surface_nst_landfill.F90 | 18 ++++++++++++++---- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index f1faa8798..5cd8f6137 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2796,7 +2796,7 @@ subroutine nst_land_fill if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldGet", rc) - print*,"- CALL FieldGet FOR TARGET GRID LANDMASK." + print*,"- CALL FieldGet FOR TARGET GRID SEAICE FRACT." call ESMF_FieldGet(seaice_fract_target_grid, & farrayPtr=fice_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& diff --git a/sorc/chgres_tools.fd/check.F90 b/sorc/chgres_tools.fd/check.F90 index 119c3245a..88a48ddb4 100644 --- a/sorc/chgres_tools.fd/check.F90 +++ b/sorc/chgres_tools.fd/check.F90 @@ -58,7 +58,8 @@ program check TILE : do tiles = 1, 6 file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) - file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" // oro_files(tiles) + file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & + // oro_files(tiles) file_ceiling="/gpfs/dell1/stmp/George.Gayno/chgres_ceiling/" // the_files(tiles) ! Open the file created using the non-fractional logic, but with diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 index 4b12b33fe..04c7709b3 100644 --- a/sorc/chgres_tools2.fd/check.F90 +++ b/sorc/chgres_tools2.fd/check.F90 @@ -66,7 +66,8 @@ program check do tiles = 1, 6 file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) - file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" // oro_files(tiles) + file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & + // oro_files(tiles) file_floor="/gpfs/dell1/stmp/George.Gayno/chgres_floor/" // the_files(tiles) ! Open the file created using the non-fractional logic, but with diff --git a/tests/chgres_cube/ftst_surface_nst_landfill.F90 b/tests/chgres_cube/ftst_surface_nst_landfill.F90 index d8d525e7b..0e023f364 100644 --- a/tests/chgres_cube/ftst_surface_nst_landfill.F90 +++ b/tests/chgres_cube/ftst_surface_nst_landfill.F90 @@ -17,6 +17,7 @@ program surface_nst_landfill use program_setup, only : fract_grid use surface_target_data, only : skin_temp_target_grid, & + seaice_fract_target_grid, & c_d_target_grid, & c_0_target_grid, & d_conv_target_grid, & @@ -51,13 +52,12 @@ program surface_nst_landfill character(len=50) :: fname - integer(esmf_kind_i8), pointer :: mask_target_ptr(:,:) integer(esmf_kind_i8), allocatable :: mask(:,:) - real(esmf_kind_r8), pointer :: skin_temp_ptr(:,:), & - tmp_ptr(:,:) + real(esmf_kind_r8), pointer :: tmp_ptr(:,:) real(esmf_kind_r8), allocatable :: skin_temp(:,:), & + ice(:,:), & tmp_array_2d(:,:), & nst_field_correct(:,:), & tref_correct(:,:),& @@ -107,14 +107,22 @@ program surface_nst_landfill name="target_grid_skin_temp", & rc=rc) + seaice_fract_target_grid = ESMF_FieldCreate(target_grid, & + typekind=ESMF_TYPEKIND_R8, & + staggerloc=ESMF_STAGGERLOC_CENTER, & + name="target_grid_ice_fract", & + rc=rc) + call create_nst_esmf_fields allocate(mask(i_target,j_target)) + allocate(ice(i_target,j_target)) allocate(skin_temp(i_target,j_target)) allocate(nst_field_correct(i_target,j_target)) allocate(tref_correct(i_target,j_target)) allocate(xz_correct(i_target,j_target)) + ice = 0 ! ice free mask = reshape((/1,1,1,1,1,0,0,1,1,0,0,1,1,1,1,1/),(/i_target,j_target/)) skin_temp = reshape((/280., 280., 280., 280., & 280., 290., 290., 280., & @@ -122,7 +130,9 @@ program surface_nst_landfill 280., 280., 280., 280./),(/i_target,j_target/)) call ESMF_FieldScatter(seamask_target_grid, mask, rootpet=0, rc=rc) call ESMF_FieldScatter(skin_temp_target_grid, skin_temp, rootpet=0, rc=rc) - deallocate(mask, skin_temp) + call ESMF_FieldScatter(seaice_fract_target_grid, ice, rootpet=0, rc=rc) + + deallocate(mask, skin_temp, ice) nst_field_correct = reshape((/-999.9, -999.9, -999.9, -999.9, & -999.9, 0., 0., -999.9, & From 67cdcaa1f1d84bae7406c1abcecc43f79b8fb248 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 27 Apr 2022 21:04:21 +0000 Subject: [PATCH 041/107] Update doxygen for program_setup.F90 Fixes #123. --- sorc/chgres_cube.fd/program_setup.F90 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sorc/chgres_cube.fd/program_setup.F90 b/sorc/chgres_cube.fd/program_setup.F90 index 2a4dadc0d..584bfe233 100644 --- a/sorc/chgres_cube.fd/program_setup.F90 +++ b/sorc/chgres_cube.fd/program_setup.F90 @@ -85,8 +85,10 @@ module program_setup integer, public :: regional = 0 !< For regional target grids. When '1' remove boundary halo region from atmospheric/surface data and !! output atmospheric boundary file. When '2' output boundary file only. Default is '0' (global grids). integer, public :: halo_bndy = 0 !< Number of row/cols of lateral halo, where pure lateral bndy conditions are applied (regional target grids). - integer, public :: halo_blend = 0 !< Number of row/cols of blending halo, where model tendencies and lateral boundary tendencies are applied. Regional target grids only. - integer, public :: nsoill_out = 4 !< Number of soil levels desired in the output data. chgres_cube can interpolate from 9 input to 4 output levels. DEFAULT: 4. + integer, public :: halo_blend = 0 !< Number of row/cols of blending halo, where model + !! tendencies and lateral boundary tendencies are applied. Regional target grids only. + integer, public :: nsoill_out = 4 !< Number of soil levels desired in the output data. + !! chgres_cube can interpolate from 9 input to 4 output levels. DEFAULT: 4. logical, public :: convert_atm = .false. !< Convert atmospheric data when true. logical, public :: convert_nst = .false. !< Convert nst data when true. @@ -94,7 +96,8 @@ module program_setup logical, public :: wam_cold_start = .false. !< When true, cold start for whole atmosphere model. - logical, public :: fract_grid = .false. + logical, public :: fract_grid = .false. !< When true, run for coupled grids (where model + !! points can be both land and non-land. ! Options for replacing vegetation/soil type, veg fraction, and lai with data from the grib2 file ! Default is to use climatology instead From 64f3469bd518a88f4c3870a818a54203c1be3b85 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 28 Apr 2022 13:42:11 +0000 Subject: [PATCH 042/107] Fix some doxygen. Fixes #123. --- sorc/chgres_cube.fd/model_grid.F90 | 1 + sorc/chgres_cube.fd/program_setup.F90 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sorc/chgres_cube.fd/model_grid.F90 b/sorc/chgres_cube.fd/model_grid.F90 index 447693062..36d42f5c6 100644 --- a/sorc/chgres_cube.fd/model_grid.F90 +++ b/sorc/chgres_cube.fd/model_grid.F90 @@ -1350,6 +1350,7 @@ end subroutine get_model_latlons !! @param [in] jdim "j" dimension of tile !! @param [out] mask land mask of tile !! @param [out] terrain terrain height of tile +!! @param [out] land_frac The fraction of the grid point that is land. !! @author George Gayno NCEP/EMC subroutine get_model_mask_terrain(orog_file, idim, jdim, mask, terrain, land_frac) diff --git a/sorc/chgres_cube.fd/program_setup.F90 b/sorc/chgres_cube.fd/program_setup.F90 index 584bfe233..2be1cc846 100644 --- a/sorc/chgres_cube.fd/program_setup.F90 +++ b/sorc/chgres_cube.fd/program_setup.F90 @@ -97,7 +97,7 @@ module program_setup logical, public :: fract_grid = .false. !< When true, run for coupled grids (where model - !! points can be both land and non-land. + !! points can be both land and non-land). ! Options for replacing vegetation/soil type, veg fraction, and lai with data from the grib2 file ! Default is to use climatology instead From 6e17ccd4e8aa3a4c8d708763db42f7473ef1bf72 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 11 May 2022 15:20:07 +0000 Subject: [PATCH 043/107] Update flag values to be very large. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 88 ++++++++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 13 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 5cd8f6137..94a4f4bf3 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2205,7 +2205,8 @@ end subroutine adjust_soil_levels !! @author George Gayno NOAA/EMC subroutine roughness - use model_grid, only : landmask_target_grid + use model_grid, only : landmask_target_grid, & + seamask_target_grid use static_data, only : veg_type_target_grid use program_setup, only : fract_grid @@ -2213,10 +2214,12 @@ subroutine roughness integer :: clb(2), cub(2), i, j, rc integer(esmf_kind_i8), pointer :: landmask_ptr(:,:) + integer(esmf_kind_i8), pointer :: seamask_ptr(:,:) real :: z0_igbp(20) real(esmf_kind_r8), pointer :: data_ptr(:,:) real(esmf_kind_r8), pointer :: data_ptr2(:,:) + real(esmf_kind_r8), pointer :: data_ptr3(:,:) real(esmf_kind_r8), pointer :: fice_ptr(:,:) real(esmf_kind_r8), pointer :: veg_type_ptr(:,:) @@ -2263,6 +2266,8 @@ subroutine roughness do i = clb(1), cub(1) if (fice_ptr(i,j) > 0.0) then data_ptr2(i,j) = 1.0 + else + data_ptr2(i,j) = -1.e20 endif enddo enddo @@ -2272,7 +2277,27 @@ subroutine roughness if (landmask_ptr(i,j) == 1) then data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0 else - data_ptr(i,j) = -9. + data_ptr(i,j) = -1.e20 + endif + enddo + enddo + + print*,"- CALL FieldGet FOR TARGET GRID Z0 WATER." + call ESMF_FieldGet(z0_water_target_grid, & + farrayPtr=data_ptr3, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + print*,"- CALL FieldGet FOR TARGET SEA MASK." + call ESMF_FieldGet(seamask_target_grid, & + farrayPtr=seamask_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) > 0.0 .or. seamask_ptr(i,j) == 0) then + data_ptr3(i,j) = -1.e20 endif enddo enddo @@ -2328,6 +2353,7 @@ subroutine qc_check real(esmf_kind_r8), pointer :: data_ptr(:,:) real(esmf_kind_r8), pointer :: data3d_ptr(:,:,:) + real(esmf_kind_r8), pointer :: ice_ptr(:,:,:) real(esmf_kind_r8), pointer :: soilmt_ptr(:,:,:) real(esmf_kind_r8), pointer :: soilml_ptr(:,:,:) real(esmf_kind_r8), pointer :: veg_greenness_ptr(:,:) @@ -2416,7 +2442,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2442,7 +2468,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2468,7 +2494,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2494,7 +2520,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -9. ! gfs physics flag value + if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2626,7 +2652,7 @@ subroutine qc_check ! skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + & ! ( (1.0 - fice_ptr(i,j)) * frz_ice ) else -! seaice_skint_ptr(i,j) = skint_ptr(i,j) + seaice_skint_ptr(i,j) = -1.e20 hice_ptr(i,j) = 0.0 endif enddo @@ -2751,8 +2777,32 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract, is skint_ptr the new sst field? need to use new -!cfract sst_target_grid here. + if (fract_grid) then + + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0) then + data3d_ptr(i,j,:) = -1.e20 + endif + enddo + enddo + + print*,"- SET FLAG FOR TARGET GRID ICE TEMPERATURE." + call ESMF_FieldGet(ice_temp_target_grid, & + farrayPtr=ice_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) == 0.0) then + ice_ptr(i,j,:) = -1.e20 + endif + enddo + enddo + + else + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then @@ -2761,6 +2811,18 @@ subroutine qc_check enddo enddo + endif + + if (fract_grid) then ! set flag value at non-land + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0) then + skint_ptr(i,j) = -1.e20 + endif + enddo + enddo + endif + return end subroutine qc_check @@ -3185,7 +3247,7 @@ subroutine create_surface_esmf_fields if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - target_ptr = init_val + target_ptr = -1.e20 print*,"- CALL FieldCreate FOR TARGET ALVWF AT NON-LAND." alvwf_nl_target_grid = ESMF_FieldCreate(target_grid, & @@ -3201,7 +3263,7 @@ subroutine create_surface_esmf_fields if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - target_ptr = init_val + target_ptr = -1.e20 print*,"- CALL FieldCreate FOR TARGET ALNSF AT NON-LAND." alnsf_nl_target_grid = ESMF_FieldCreate(target_grid, & @@ -3217,7 +3279,7 @@ subroutine create_surface_esmf_fields if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - target_ptr = init_val + target_ptr = -1.e20 print*,"- CALL FieldCreate FOR TARGET ALNWF AT NON-LAND." alnwf_nl_target_grid = ESMF_FieldCreate(target_grid, & @@ -3233,7 +3295,7 @@ subroutine create_surface_esmf_fields if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - target_ptr = init_val + target_ptr = -1.e20 endif ! fract_grid print*,"- CALL FieldCreate FOR TARGET GRID CANOPY MOISTURE CONTENT." From 49ebe0516ef99f483c5e5611e375dc1f01a45bfb Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 13 May 2022 20:59:20 +0000 Subject: [PATCH 044/107] For ice column temperature, only output the top two layers. The other layers are not used by the ice model. Fixes #123. --- sorc/chgres_cube.fd/write_data.F90 | 41 ++++++++++++++++++++++-------- sorc/chgres_tools2.fd/check.F90 | 4 +-- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index e4b975775..1cb5b2715 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1889,9 +1889,9 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: fsize=65536, initial = 0 integer :: header_buffer_val = 16384 - integer :: dim_x, dim_y, dim_lsoil, dim_time + integer :: dim_x, dim_y, dim_lsoil, dim_ice, dim_time integer :: error, i, ncid, tile - integer :: id_x, id_y, id_lsoil + integer :: id_x, id_y, id_lsoil, id_ice integer :: id_slmsk, id_time integer :: id_lat, id_lon, id_tg3_ice integer :: id_tsfcl, id_tsea, id_sheleg, id_sheleg_ice, id_tg3 @@ -1992,6 +1992,10 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING YAXIS DIMENSION' ) error = nf90_def_dim(ncid, 'zaxis_1', lsoil_target, dim_lsoil) call netcdf_err(error, 'DEFINING ZAXIS DIMENSION' ) + if (fract_grid) then + error = nf90_def_dim(ncid, 'zaxis_2', 2, dim_ice) + call netcdf_err(error, 'DEFINING ZAXIS2 DIMENSION' ) + endif error = nf90_def_dim(ncid, 'Time', 1, dim_time) call netcdf_err(error, 'DEFINING TIME DIMENSION' ) @@ -2023,6 +2027,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_lsoil, "cartesian_axis", "Z") call netcdf_err(error, 'WRITING ZAXIS_1 FIELD' ) + if (fract_grid) then + error = nf90_def_var(ncid, 'zaxis_2', NF90_FLOAT, (/dim_ice/), id_ice) + call netcdf_err(error, 'DEFINING ZAXIS_2 FIELD' ) + error = nf90_put_att(ncid, id_ice, "long_name", "zaxis_2") + call netcdf_err(error, 'DEFINING ZAXIS_2 LONG NAME' ) + error = nf90_put_att(ncid, id_ice, "units", "none") + call netcdf_err(error, 'DEFINING ZAXIS_2 UNITS' ) + error = nf90_put_att(ncid, id_ice, "cartesian_axis", "Z") + call netcdf_err(error, 'WRITING ZAXIS_2 FIELD' ) + endif + error = nf90_def_var(ncid, 'Time', NF90_FLOAT, dim_time, id_time) call netcdf_err(error, 'DEFINING TIME FIELD' ) error = nf90_put_att(ncid, id_time, "long_name", "Time") @@ -2482,7 +2497,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING SLC COORD' ) if(fract_grid)then - error = nf90_def_var(ncid, 'stc_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_lsoil,dim_time/), id_stc_ice) + error = nf90_def_var(ncid, 'stc_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_ice,dim_time/), id_stc_ice) call netcdf_err(error, 'DEFINING STC_ICE' ) error = nf90_put_att(ncid, id_stc_ice, "long_name", "stc_ice") call netcdf_err(error, 'DEFINING STC_ICE LONG NAME' ) @@ -2666,6 +2681,10 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then error = nf90_put_var( ncid, id_lsoil, lsoil_data) call netcdf_err(error, 'WRITING ZAXIS RECORD' ) + if (fract_grid) then + error = nf90_put_var( ncid, id_ice, (/1,2/)) + call netcdf_err(error, 'WRITING ZAXIS2 RECORD' ) + endif error = nf90_put_var( ncid, id_x, x_data) call netcdf_err(error, 'WRITING XAXIS RECORD' ) error = nf90_put_var( ncid, id_y, y_data) @@ -3181,16 +3200,16 @@ subroutine write_fv3_sfc_data_netcdf(localpet) ! ice temperature if(fract_grid)then - print*,"- CALL FieldGather FOR TARGET GRID sea ice TEMPERATURE FOR TILE: ", tile - call ESMF_FieldGather(ice_temp_target_grid, data_one_tile_3d, rootPet=0, tile=tile, rc=error) - if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + print*,"- CALL FieldGather FOR TARGET GRID sea ice TEMPERATURE FOR TILE: ", tile + call ESMF_FieldGather(ice_temp_target_grid, data_one_tile_3d, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", error) - if (localpet == 0) then - dum3d(:,:,:) = data_one_tile_3d(istart:iend, jstart:jend,:) - error = nf90_put_var( ncid, id_stc_ice, dum3d, start=(/1,1,1,1/), count=(/i_target_out,j_target_out,lsoil_target,1/)) - call netcdf_err(error, 'WRITING sea ice TEMP RECORD' ) - endif + if (localpet == 0) then + dum3d(:,:,:) = data_one_tile_3d(istart:iend, jstart:jend,:) + error = nf90_put_var( ncid, id_stc_ice, dum3d(:,:,1:2), start=(/1,1,1,1/), count=(/i_target_out,j_target_out,2,1/)) + call netcdf_err(error, 'WRITING sea ice TEMP RECORD' ) + endif endif ! soil temperature diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 index 04c7709b3..fdf877417 100644 --- a/sorc/chgres_tools2.fd/check.F90 +++ b/sorc/chgres_tools2.fd/check.F90 @@ -219,7 +219,7 @@ program check enddo - if(.not.allocated(dummy_frac3d)) allocate(dummy_frac3d(idim,jdim,4)) + if(.not.allocated(dummy_frac3d)) allocate(dummy_frac3d(idim,jdim,2)) if(.not.allocated(dummy_floor3d)) allocate(dummy_floor3d(idim,jdim,4)) do var = 1, num_var3d @@ -236,7 +236,7 @@ program check error=nf90_get_var(ncid_floor,varid_floor,dummy_floor3d) call netcdf_err(error, 'reading floor field' ) - do n = 1, 4 + do n = 1, 2 print*,'frac field level ',n,maxval(dummy_frac3d(:,:,n)),minval(dummy_frac3d(:,:,n)) print*,'floor field level ',n,maxval(dummy_floor3d(:,:,n)),minval(dummy_floor3d(:,:,n)) From 858d50c84374653a7f25cb1f101226120f7ae5c3 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 13 May 2022 21:27:27 +0000 Subject: [PATCH 045/107] Update flag value for sea ice substrate temperature. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 94a4f4bf3..79ff019aa 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2684,6 +2684,8 @@ subroutine qc_check do i = clb(1), cub(1) if (fice_ptr(i,j) > 0.0) then ! sea ice data_ptr(i,j) = frz_ice + else + data_ptr(i,j) = -1.e20 endif enddo enddo From edff86e1c41e636ec32b1352545f32a6f1ef19c1 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 7 Jun 2022 20:44:32 +0000 Subject: [PATCH 046/107] Update check tooks for Hera. Fixes #123. --- sorc/chgres_tools.fd/check.F90 | 11 ++++++++--- sorc/chgres_tools2.fd/check.F90 | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/sorc/chgres_tools.fd/check.F90 b/sorc/chgres_tools.fd/check.F90 index 88a48ddb4..83dd5e77c 100644 --- a/sorc/chgres_tools.fd/check.F90 +++ b/sorc/chgres_tools.fd/check.F90 @@ -57,10 +57,15 @@ program check TILE : do tiles = 1, 6 - file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) - file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & + file_frac="/scratch2/NCEPDEV/stmp1/George.Gayno/chgres_fractional/" // the_files(tiles) + file_orog_frac="/scratch1/NCEPDEV/da/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & // oro_files(tiles) - file_ceiling="/gpfs/dell1/stmp/George.Gayno/chgres_ceiling/" // the_files(tiles) + file_ceiling="/scratch2/NCEPDEV/stmp1/George.Gayno/chgres_ceiling/" // the_files(tiles) + +!file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) +!file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & +! // oro_files(tiles) +!file_ceiling="/gpfs/dell1/stmp/George.Gayno/chgres_ceiling/" // the_files(tiles) ! Open the file created using the non-fractional logic, but with ! slmsk modified to be ceiling of the land fraction. diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 index fdf877417..4c663de8d 100644 --- a/sorc/chgres_tools2.fd/check.F90 +++ b/sorc/chgres_tools2.fd/check.F90 @@ -65,10 +65,15 @@ program check do tiles = 1, 6 - file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) - file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & + file_frac="/scratch2/NCEPDEV/stmp1/George.Gayno/chgres_fractional/" // the_files(tiles) + file_orog_frac="/scratch1/NCEPDEV/da/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & // oro_files(tiles) - file_floor="/gpfs/dell1/stmp/George.Gayno/chgres_floor/" // the_files(tiles) + file_floor="/scratch2/NCEPDEV/stmp1/George.Gayno/chgres_floor/" // the_files(tiles) + +!file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) +!file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & +! // oro_files(tiles) +!file_floor="/gpfs/dell1/stmp/George.Gayno/chgres_floor/" // the_files(tiles) ! Open the file created using the non-fractional logic, but with ! slmsk modified to be floor of the land fraction. From 3adea876ccb690877eed7e7c0a8cf1dcc01c9ad4 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 8 Jun 2022 18:18:54 +0000 Subject: [PATCH 047/107] Change flag value for substrate temperature at non-land points. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 79ff019aa..21f5bf65f 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2362,6 +2362,8 @@ subroutine qc_check real(esmf_kind_r8), pointer :: skint_ptr(:,:) real(esmf_kind_r8), pointer :: fice_ptr(:,:) real(esmf_kind_r8), pointer :: hice_ptr(:,:) + real(esmf_kind_r8), pointer :: tg3_ptr(:,:) + real(esmf_kind_r8), pointer :: tg3_ice_ptr(:,:) print*,"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK." call ESMF_FieldGet(landmask_target_grid, & @@ -2676,16 +2678,29 @@ subroutine qc_check if (fract_grid) then call ESMF_FieldGet(seaice_substrate_temp_target_grid, & - farrayPtr=data_ptr, rc=rc) + farrayPtr=tg3_ice_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) > 0.0) then ! sea ice - data_ptr(i,j) = frz_ice + tg3_ice_ptr(i,j) = frz_ice else - data_ptr(i,j) = -1.e20 + tg3_ice_ptr(i,j) = -1.e20 + endif + enddo + enddo + + call ESMF_FieldGet(substrate_temp_target_grid, & + farrayPtr=tg3_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0.0) then ! sea ice + tg3_ptr(i,j) = -1.e20 endif enddo enddo @@ -2693,16 +2708,16 @@ subroutine qc_check else call ESMF_FieldGet(substrate_temp_target_grid, & - farrayPtr=data_ptr, rc=rc) + farrayPtr=tg3_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) > 0.0) then ! sea ice - data_ptr(i,j) = frz_ice + tg3_ptr(i,j) = frz_ice elseif (landmask_ptr(i,j) == 0) then ! open water flag value. - data_ptr(i,j) = skint_ptr(i,j) + tg3_ptr(i,j) = skint_ptr(i,j) endif enddo enddo From 2908295f5bb68444b7c16962377e828a0020ddbf Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 9 Jun 2022 13:28:52 +0000 Subject: [PATCH 048/107] Update missing flag value for snow (at land) fields. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 50 ++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 21f5bf65f..2912af427 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2730,14 +2730,23 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract this should work for fractional grids. - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then ! open water - data_ptr(i,j) = 0.0 - end if - enddo - enddo + if (fract_grid) then + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) /= 1) then ! not land + data_ptr(i,j) = -1.e20 + end if + enddo + enddo + else + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then + data_ptr(i,j) = 0.0 + end if + enddo + enddo + endif print*,"- ZERO OUT TARGET GRID SNOW LIQ AT OPEN WATER." call ESMF_FieldGet(snow_liq_equiv_target_grid, & @@ -2745,14 +2754,23 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract this should work for fractional grids. - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then ! open water - data_ptr(i,j) = 0.0 - endif - enddo - enddo + if (fract_grid) then + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) /= 1) then ! not land + data_ptr(i,j) = -1.e20 + end if + enddo + enddo + else + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then + data_ptr(i,j) = 0.0 + end if + enddo + enddo + endif print*,"- SET NON-LAND FLAG VALUE FOR TARGET GRID TOTAL SOIL MOISTURE." call ESMF_FieldGet(soilm_tot_target_grid, & From f47ae466b751d9711cdfd3af0f4541d6b326f46c Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 9 Jun 2022 16:14:39 +0000 Subject: [PATCH 049/107] Update missing flag at sea ice snow variables. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 27 +++++++++++++++++++++++++++ sorc/chgres_tools2.fd/check.F90 | 4 +++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 2912af427..d37506b4d 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2364,6 +2364,8 @@ subroutine qc_check real(esmf_kind_r8), pointer :: hice_ptr(:,:) real(esmf_kind_r8), pointer :: tg3_ptr(:,:) real(esmf_kind_r8), pointer :: tg3_ice_ptr(:,:) + real(esmf_kind_r8), pointer :: snod_ptr(:,:) + real(esmf_kind_r8), pointer :: snol_ptr(:,:) print*,"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK." call ESMF_FieldGet(landmask_target_grid, & @@ -2724,6 +2726,31 @@ subroutine qc_check endif + if (fract_grid) then + + print*,"- SET MISSING FLAG AT TARGET GRID SNOW DEPTH AT ICE." + call ESMF_FieldGet(snow_depth_at_ice_target_grid, & + farrayPtr=snod_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + print*,"- SET MISSING FLAG AT TARGET GRID SNOW LIQ EQUIV AT ICE." + call ESMF_FieldGet(snow_liq_equiv_at_ice_target_grid, & + farrayPtr=snol_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) == 0.0) then + snol_ptr(i,j) = -1.e20 + snod_ptr(i,j) = -1.e20 + end if + enddo + enddo + + endif + print*,"- ZERO OUT TARGET GRID SNOW DEPTH AT OPEN WATER." call ESMF_FieldGet(snow_depth_target_grid, & farrayPtr=data_ptr, rc=rc) diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 index 4c663de8d..6c232db22 100644 --- a/sorc/chgres_tools2.fd/check.F90 +++ b/sorc/chgres_tools2.fd/check.F90 @@ -169,12 +169,14 @@ program check if (trim(varname_frac(var)) == 'tg3_ice' .or. & trim(varname_frac(var)) == 'tisfc' .or. & + trim(varname_frac(var)) == 'snwdph_ice' .or. & + trim(varname_frac(var)) == 'sheleg_ice' .or. & trim(varname_frac(var)) == 'zorl_ice') then ! check at ice only. do j = 1, jdim do i = 1, idim if (nint(slmsk(i,j)) == 2) then if (dummy_floor(i,j) /= dummy_frac(i,j)) then - print*,'bad tg3 pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) + print*,'bad ice pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) stop endif endif From bd463a08678aac7ec7beb15e2c5cf1e5679e563b Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 13 Jun 2022 21:12:33 +0000 Subject: [PATCH 050/107] Set open water SST and roughness fields at points with partial ice. Adjust flag value to large negative number. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 35 +++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index d37506b4d..48b707caf 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -903,14 +903,18 @@ subroutine interp(localpet) mask_input_ptr = 0 where (nint(landmask_input_ptr) == 0) mask_input_ptr = 1 -!cfract dont include any points with ice. +!cfract include points that are fractional ice. !cfract use seamask_target, which is 1 if there is some water. !cfract then remove points where fice is > 0. !cfract We want points with at least some water, but no ice. mask_target_ptr = 0 where (seamask_target_ptr == 1) mask_target_ptr = 1 - where (seaice_fract_target_ptr > 0.0) mask_target_ptr = 0 + if (fract_grid) then + where (seaice_fract_target_ptr == 1.0_esmf_kind_r8) mask_target_ptr = 0 + else + where (seaice_fract_target_ptr > 0.0) mask_target_ptr = 0 + endif method=ESMF_REGRIDMETHOD_CONSERVE isrctermprocessing = 1 @@ -1038,7 +1042,11 @@ subroutine interp(localpet) allocate(water_target_one_tile(i_target,j_target)) water_target_one_tile = 0 where(mask_target_one_tile == 1) water_target_one_tile = 1 - where(fice_target_one_tile > 0.0) water_target_one_tile = 0 + if(fract_grid) then + where(fice_target_one_tile == 1.0_esmf_kind_r8) water_target_one_tile = 0 + else + where(fice_target_one_tile > 0.0) water_target_one_tile = 0 + endif endif call search_many(num_fields,bundle_water_target,data_one_tile, water_target_one_tile,& @@ -2296,7 +2304,7 @@ subroutine roughness do j = clb(2), cub(2) do i = clb(1), cub(1) - if (fice_ptr(i,j) > 0.0 .or. seamask_ptr(i,j) == 0) then + if (fice_ptr(i,j) == 1.0_esmf_kind_r8 .or. seamask_ptr(i,j) == 0) then data_ptr3(i,j) = -1.e20 endif enddo @@ -2675,6 +2683,25 @@ subroutine qc_check enddo endif + if (fract_grid) then + + print*,"- SET TARGET GRID SST FLAG VALUE." + + call ESMF_FieldGet(sst_target_grid, & + farrayPtr=data_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) == 1.0_esmf_kind_r8 .or. seamask_ptr(i,j) == 0.0) then + data_ptr(i,j) = -1.e20 + endif + enddo + enddo + + endif + print*,"- SET TARGET GRID SUBSTRATE TEMP AT ICE." if (fract_grid) then From 0e7157e20100f5dc7ea8400de751e6292e646e25 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 22 Jun 2022 17:57:16 +0000 Subject: [PATCH 051/107] When processing fractional grids, there can be numerous points with ice fractions very close to 1. To reduce the number of mixed points with very large ice content, round up all points with 95% coverage to 100% coverage. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 12 +++++++++++- sorc/chgres_tools2.fd/check.F90 | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 48b707caf..40c040079 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -357,6 +357,7 @@ subroutine interp(localpet) real(esmf_kind_r8), pointer :: landmask_input_ptr(:,:) real(esmf_kind_r8), pointer :: veg_type_input_ptr(:,:) real(esmf_kind_r8), allocatable :: veg_type_target_one_tile(:,:) + real(esmf_kind_r8) :: ice_lim type(esmf_regridmethod_flag) :: method type(esmf_routehandle) :: regrid_bl_no_mask @@ -738,10 +739,19 @@ subroutine interp(localpet) latitude=latitude_one_tile) endif +! When running with fractional grids, to reduce the number of points with small amounts of open water, +! set any point with ice between 95-100% to 100%. + + if (fract_grid) then + ice_lim = 0.95_esmf_kind_r8 + else + ice_lim = 1.0_esmf_kind_r8 + endif + if (localpet == 0) then do j = 1, j_target do i = 1, i_target - if (data_one_tile(i,j) > 1.0_esmf_kind_r8) then + if (data_one_tile(i,j) > ice_lim) then data_one_tile(i,j) = 1.0_esmf_kind_r8 endif if (data_one_tile(i,j) < 0.15_esmf_kind_r8) data_one_tile(i,j) = 0.0_esmf_kind_r8 diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 index 6c232db22..19f92edf5 100644 --- a/sorc/chgres_tools2.fd/check.F90 +++ b/sorc/chgres_tools2.fd/check.F90 @@ -165,6 +165,10 @@ program check error=nf90_get_var(ncid_floor,varid_floor,dummy_floor) call netcdf_err(error, 'reading floor field' ) + if (trim(varname_floor(var)) == 'fice') then + where(dummy_floor > 0.95) dummy_floor = 1.00 + endif + print*,'floor field ',maxval(dummy_floor),minval(dummy_floor) if (trim(varname_frac(var)) == 'tg3_ice' .or. & From 9bfc3abcaa3e7ce8c91f52f4a0bebb3c1473b236 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 26 Sep 2022 14:32:22 +0000 Subject: [PATCH 052/107] Merge submodule updates to branch. Fixes #123. --- ccpp-physics | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccpp-physics b/ccpp-physics index 3405ff171..12c115e99 160000 --- a/ccpp-physics +++ b/ccpp-physics @@ -1 +1 @@ -Subproject commit 3405ff171d7fa55d6aa7fb45b316146516c6e3ca +Subproject commit 12c115e992d3a265eaaa67d72fcbdb3a6f21195f From 85b3fd758a91cadc88cfc7accd278da56545795f Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 17 May 2023 19:45:45 +0000 Subject: [PATCH 053/107] Write out only one snow depth and equiv record for both land and ice. Points with land and ice are given the land value. This is how Shan's method handles it. And this is how the model expects it. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 12 +++- sorc/chgres_cube.fd/write_data.F90 | 95 +++++++++++++++--------------- 2 files changed, 59 insertions(+), 48 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index cc6e4507f..0f835fa8a 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2818,7 +2818,11 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) then ! not land - data_ptr(i,j) = -1.e20 + if (fice_ptr(i,j) > 0.0) then + data_ptr(i,j) = snod_ptr(i,j) + else + data_ptr(i,j) = -1.e20 + endif end if enddo enddo @@ -2842,7 +2846,11 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) then ! not land - data_ptr(i,j) = -1.e20 + if (fice_ptr(i,j) > 0.0) then + data_ptr(i,j) = snol_ptr(i,j) + else + data_ptr(i,j) = -1.e20 + endif end if enddo enddo diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index e586022fc..daa3687e9 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1831,8 +1831,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) srflag_target_grid, & snow_liq_equiv_target_grid, & snow_depth_target_grid, & - snow_liq_equiv_at_ice_target_grid, & - snow_depth_at_ice_target_grid, & +! snow_liq_equiv_at_ice_target_grid, & +! snow_depth_at_ice_target_grid, & t2m_target_grid, & tprcp_target_grid, & ustar_target_grid, & @@ -1889,7 +1889,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_x, id_y, id_lsoil, id_ice integer :: id_slmsk, id_time integer :: id_lat, id_lon, id_tg3_ice - integer :: id_tsfcl, id_tsea, id_sheleg, id_sheleg_ice, id_tg3 +!integer :: id_tsfcl, id_tsea, id_sheleg, id_sheleg_ice, id_tg3 + integer :: id_tsfcl, id_tsea, id_sheleg, id_tg3 integer :: id_zorl, id_zorl_ice, id_alvsf, id_alvwf integer :: id_zorl_water, id_alvsf_nl integer :: id_alvwf_nl, id_alnsf_nl, id_alnwf_nl @@ -1899,7 +1900,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_facsf, id_facwf, id_uustar integer :: id_ffmm, id_ffhh, id_hice integer :: id_fice, id_tisfc, id_tprcp - integer :: id_srflag, id_snwdph, id_snwdph_ice, id_shdmin +!integer :: id_srflag, id_snwdph, id_snwdph_ice, id_shdmin + integer :: id_srflag, id_snwdph, id_shdmin integer :: id_shdmax, id_slope, id_snoalb integer :: id_lai, id_stc_ice integer :: id_stc, id_smc, id_slc @@ -2093,16 +2095,16 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_sheleg, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SHELEG COORD' ) - if(fract_grid)then - error = nf90_def_var(ncid, 'sheleg_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_ice) - call netcdf_err(error, 'DEFINING SHELEG AT ICE' ) - error = nf90_put_att(ncid, id_sheleg_ice, "long_name", "sheleg_ice") - call netcdf_err(error, 'DEFINING SHELEG ICE LONG NAME' ) - error = nf90_put_att(ncid, id_sheleg_ice, "units", "none") - call netcdf_err(error, 'DEFINING SHELEG AT ICE UNITS' ) - error = nf90_put_att(ncid, id_sheleg_ice, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING SHELEG AT ICE COORD' ) - endif +! if(fract_grid)then +! error = nf90_def_var(ncid, 'sheleg_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_ice) +! call netcdf_err(error, 'DEFINING SHELEG AT ICE' ) +! error = nf90_put_att(ncid, id_sheleg_ice, "long_name", "sheleg_ice") +! call netcdf_err(error, 'DEFINING SHELEG ICE LONG NAME' ) +! error = nf90_put_att(ncid, id_sheleg_ice, "units", "none") +! call netcdf_err(error, 'DEFINING SHELEG AT ICE UNITS' ) +! error = nf90_put_att(ncid, id_sheleg_ice, "coordinates", "geolon geolat") +! call netcdf_err(error, 'DEFINING SHELEG AT ICE COORD' ) +! endif error = nf90_def_var(ncid, 'tg3', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3) call netcdf_err(error, 'DEFINING TG3' ) @@ -2405,16 +2407,16 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_snwdph, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SNWDPH COORD' ) - if(fract_grid)then - error = nf90_def_var(ncid, 'snwdph_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph_ice) - call netcdf_err(error, 'DEFINING SNWDPH AT ICE' ) - error = nf90_put_att(ncid, id_snwdph_ice, "long_name", "snwdph_ice") - call netcdf_err(error, 'DEFINING SNWDPH AT ICE LONG NAME' ) - error = nf90_put_att(ncid, id_snwdph_ice, "units", "none") - call netcdf_err(error, 'DEFINING SNWDPH AT ICE UNITS' ) - error = nf90_put_att(ncid, id_snwdph_ice, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING SNWDPH AT ICE COORD' ) - endif +! if(fract_grid)then +! error = nf90_def_var(ncid, 'snwdph_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph_ice) +! call netcdf_err(error, 'DEFINING SNWDPH AT ICE' ) +! error = nf90_put_att(ncid, id_snwdph_ice, "long_name", "snwdph_ice") +! call netcdf_err(error, 'DEFINING SNWDPH AT ICE LONG NAME' ) +! error = nf90_put_att(ncid, id_snwdph_ice, "units", "none") +! call netcdf_err(error, 'DEFINING SNWDPH AT ICE UNITS' ) +! error = nf90_put_att(ncid, id_snwdph_ice, "coordinates", "geolon geolat") +! call netcdf_err(error, 'DEFINING SNWDPH AT ICE COORD' ) +! endif error = nf90_def_var(ncid, 'shdmin', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_shdmin) call netcdf_err(error, 'DEFINING SHDMIN' ) @@ -2721,18 +2723,18 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SNOW LIQ EQUIV RECORD' ) endif - if(fract_grid) then - print*,"- CALL FieldGather FOR TARGET GRID SNOW LIQ EQUIV at ice FOR TILE: ", tile - call ESMF_FieldGather(snow_liq_equiv_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) - if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGather", error) +! if(fract_grid) then +! print*,"- CALL FieldGather FOR TARGET GRID SNOW LIQ EQUIV at ice FOR TILE: ", tile +! call ESMF_FieldGather(snow_liq_equiv_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) +! if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & +! call error_handler("IN FieldGather", error) - if (localpet == 0) then - dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - error = nf90_put_var( ncid, id_sheleg_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING SNOW LIQ EQUIV at ice RECORD' ) - endif - endif +! if (localpet == 0) then +! dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) +! error = nf90_put_var( ncid, id_sheleg_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) +! call netcdf_err(error, 'WRITING SNOW LIQ EQUIV at ice RECORD' ) +! endif +! endif print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH FOR TILE: ", tile call ESMF_FieldGather(snow_depth_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) @@ -2745,18 +2747,19 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SNWDPH RECORD' ) endif - if (fract_grid)then - print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH at ice FOR TILE: ", tile - call ESMF_FieldGather(snow_depth_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) - if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGather", error) +! if (fract_grid)then +! print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH at ice FOR TILE: ", tile +! call ESMF_FieldGather(snow_depth_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) +! if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & +! call error_handler("IN FieldGather", error) - if (localpet == 0) then - dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - error = nf90_put_var( ncid, id_snwdph_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING SNWDPH at ice RECORD' ) - endif - endif +! if (localpet == 0) then +! dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) +! error = nf90_put_var( ncid, id_snwdph_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) +! call netcdf_err(error, 'WRITING SNWDPH at ice RECORD' ) +! endif + +! endif print*,"- CALL FieldGather FOR TARGET GRID SLOPE TYPE FOR TILE: ", tile call ESMF_FieldGather(slope_type_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) From e483fa67b1742dfb300726110fcea5c3b6c6513d Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 19 May 2023 15:31:59 +0000 Subject: [PATCH 054/107] Change the flag value for the skin temperature records so the model logic does not recompute these fields. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 0f835fa8a..c56097715 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2694,7 +2694,7 @@ subroutine qc_check ! skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + & ! ( (1.0 - fice_ptr(i,j)) * frz_ice ) else - seaice_skint_ptr(i,j) = -1.e20 + seaice_skint_ptr(i,j) = 1.e20 hice_ptr(i,j) = 0.0 endif enddo @@ -2725,7 +2725,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 1.0_esmf_kind_r8 .or. seamask_ptr(i,j) == 0.0) then - data_ptr(i,j) = -1.e20 + data_ptr(i,j) = 1.e20 endif enddo enddo @@ -2944,7 +2944,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0) then - skint_ptr(i,j) = -1.e20 + skint_ptr(i,j) = 1.e20 endif enddo enddo From 1731f13177fa2e1d199cbe877c3ec0a8186bc202 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 22 May 2023 14:25:14 +0000 Subject: [PATCH 055/107] Update roughness flag values so model does not recompute the roughness values. Set mandatory 'zorl' record to all flag values so the records at land, ice and water are used. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 6 ++--- sorc/chgres_cube.fd/write_data.F90 | 37 +++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index c56097715..0adc4c8a4 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2305,7 +2305,7 @@ subroutine roughness if (fice_ptr(i,j) > 0.0) then data_ptr2(i,j) = 1.0 else - data_ptr2(i,j) = -1.e20 + data_ptr2(i,j) = 1.e20 endif enddo enddo @@ -2315,7 +2315,7 @@ subroutine roughness if (landmask_ptr(i,j) == 1) then data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0 else - data_ptr(i,j) = -1.e20 + data_ptr(i,j) = 1.e20 endif enddo enddo @@ -2335,7 +2335,7 @@ subroutine roughness do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 1.0_esmf_kind_r8 .or. seamask_ptr(i,j) == 0) then - data_ptr3(i,j) = -1.e20 + data_ptr3(i,j) = 1.e20 endif enddo enddo diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index daa3687e9..586aa954b 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1891,7 +1891,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_lat, id_lon, id_tg3_ice !integer :: id_tsfcl, id_tsea, id_sheleg, id_sheleg_ice, id_tg3 integer :: id_tsfcl, id_tsea, id_sheleg, id_tg3 - integer :: id_zorl, id_zorl_ice, id_alvsf, id_alvwf + integer :: id_zorl, id_zorl_land, id_zorl_ice, id_alvsf, id_alvwf integer :: id_zorl_water, id_alvsf_nl integer :: id_alvwf_nl, id_alnsf_nl, id_alnwf_nl integer :: id_alnsf, id_alnwf, id_vfrac @@ -2126,7 +2126,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING TG3_ICE COORD' ) endif - if(.not.fract_grid)then +! if(.not.fract_grid)then error = nf90_def_var(ncid, 'zorl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl) call netcdf_err(error, 'DEFINING ZORL' ) error = nf90_put_att(ncid, id_zorl, "long_name", "zorl") @@ -2136,17 +2136,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_zorl, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ZORL COORD' ) - else - error = nf90_def_var(ncid, 'zorll', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl) +! else + error = nf90_def_var(ncid, 'zorll', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_land) call netcdf_err(error, 'DEFINING ZORLL' ) - error = nf90_put_att(ncid, id_zorl, "long_name", "zorll") + error = nf90_put_att(ncid, id_zorl_land, "long_name", "zorll") call netcdf_err(error, 'DEFINING ZORLL LONG NAME' ) - error = nf90_put_att(ncid, id_zorl, "units", "none") + error = nf90_put_att(ncid, id_zorl_land, "units", "none") call netcdf_err(error, 'DEFINING ZORLL UNITS' ) - error = nf90_put_att(ncid, id_zorl, "coordinates", "geolon geolat") + error = nf90_put_att(ncid, id_zorl_land, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ZORLL COORD' ) - error = nf90_def_var(ncid, 'zorl_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_ice) + error = nf90_def_var(ncid, 'zorli', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_ice) call netcdf_err(error, 'DEFINING ZORL_ICE' ) error = nf90_put_att(ncid, id_zorl_ice, "long_name", "zorl_ice") call netcdf_err(error, 'DEFINING ZORL_ICE LONG NAME' ) @@ -2155,7 +2155,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_zorl_ice, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ZORL_ICE COORD' ) - error = nf90_def_var(ncid, 'zorl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_water) + error = nf90_def_var(ncid, 'zorlw', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_water) call netcdf_err(error, 'DEFINING ZORL' ) error = nf90_put_att(ncid, id_zorl_water, "long_name", "zorl") call netcdf_err(error, 'DEFINING ZORL LONG NAME' ) @@ -2163,7 +2163,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ZORL UNITS' ) error = nf90_put_att(ncid, id_zorl_water, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ZORL COORD' ) - endif +! endif error = nf90_def_var(ncid, 'alvsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvsf) call netcdf_err(error, 'DEFINING ALVSF' ) @@ -2778,12 +2778,25 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call error_handler("IN FieldGather", error) if (localpet == 0) then - dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) +! dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + dum2d(:,:) = 1.e20 error = nf90_put_var( ncid, id_zorl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING Z0 RECORD' ) endif if(fract_grid)then + + print*,"- CALL FieldGather FOR TARGET GRID Z0_land FOR TILE: ", tile + call ESMF_FieldGather(z0_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_zorl_land, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING Z0_LAND RECORD' ) + endif + print*,"- CALL FieldGather FOR TARGET GRID Z0_ICE FOR TILE: ", tile call ESMF_FieldGather(z0_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2805,6 +2818,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_zorl_water, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING Z0_WATER RECORD' ) endif + + endif print*,"- CALL FieldGather FOR TARGET GRID MAX SNOW ALBEDO FOR TILE: ", tile From 9277a6483908c46f884b4ae1d6c9bc43050ddb6c Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 24 May 2023 14:10:34 +0000 Subject: [PATCH 056/107] Update computation of slmsk to match how the model computes it in the i/o routine. Fixes #123. --- sorc/chgres_cube.fd/model_grid.F90 | 5 ----- sorc/chgres_cube.fd/surface.F90 | 16 +++++++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sorc/chgres_cube.fd/model_grid.F90 b/sorc/chgres_cube.fd/model_grid.F90 index b3840c996..30ffabae4 100644 --- a/sorc/chgres_cube.fd/model_grid.F90 +++ b/sorc/chgres_cube.fd/model_grid.F90 @@ -417,8 +417,6 @@ subroutine define_input_grid_mosaic(localpet, npets) integer :: extra, error, ncid integer, allocatable :: decomptile(:,:) - integer(esmf_kind_i8), allocatable :: landmask_one_tile(:,:) - real(esmf_kind_r8), allocatable :: latitude_one_tile(:,:) real(esmf_kind_r8), allocatable :: latitude_s_one_tile(:,:) real(esmf_kind_r8), allocatable :: latitude_w_one_tile(:,:) @@ -553,7 +551,6 @@ subroutine define_input_grid_mosaic(localpet, npets) allocate(latitude_one_tile(i_input,j_input)) allocate(latitude_s_one_tile(i_input,jp1_input)) allocate(latitude_w_one_tile(ip1_input,j_input)) - allocate(landmask_one_tile(i_input,j_input)) else allocate(longitude_one_tile(0,0)) allocate(longitude_s_one_tile(0,0)) @@ -561,7 +558,6 @@ subroutine define_input_grid_mosaic(localpet, npets) allocate(latitude_one_tile(0,0)) allocate(latitude_s_one_tile(0,0)) allocate(latitude_w_one_tile(0,0)) - allocate(landmask_one_tile(0,0)) endif do tile = 1, num_tiles_input_grid @@ -603,7 +599,6 @@ subroutine define_input_grid_mosaic(localpet, npets) deallocate(latitude_one_tile) deallocate(latitude_s_one_tile) deallocate(latitude_w_one_tile) - deallocate(landmask_one_tile) end subroutine define_input_grid_mosaic diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 0adc4c8a4..89fe7f471 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -3807,7 +3807,10 @@ subroutine update_landmask where(ice_ptr > 0.0) mask_ptr = 2 - else + else ! Fractional grid. The model requires this record be present. However, + ! the data is recomputed in FV3GFS_io.F90 after it is read in. Here, + ! compute it using the same algorithm as the model and output it as + ! a diagnostic. print*,"- GET TARGET land fraction." call ESMF_FieldGet(land_frac_target_grid, & @@ -3820,10 +3823,13 @@ subroutine update_landmask do j = clb(2), cub(2) do i = clb(1), cub(1) - if(ice_ptr(i,j) > 0.0) then - mask_ptr(i,j) = 2 - else - mask_ptr(i,j) = int(land_frac_ptr(i,j)) + mask_ptr(i,j) = ceiling(land_frac_ptr(i,j)) + if (mask_ptr(i,j) /= 1) then + if(ice_ptr(i,j) > 0.0) then + mask_ptr(i,j) = 2 + else + mask_ptr(i,j) = 0 + endif endif enddo From 0629fdfb985aab53a37b34094ea76d2412e21e2c Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 25 May 2023 18:56:26 +0000 Subject: [PATCH 057/107] Change record name for ice column temperatures to 'tiice' as expected by the model. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 2 +- sorc/chgres_cube.fd/write_data.F90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 89fe7f471..d5416083e 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2923,7 +2923,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 0.0) then - ice_ptr(i,j,:) = -1.e20 + ice_ptr(i,j,:) = 1.e20 endif enddo enddo diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 586aa954b..2c9882a91 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -2493,7 +2493,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING SLC COORD' ) if(fract_grid)then - error = nf90_def_var(ncid, 'stc_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_ice,dim_time/), id_stc_ice) + error = nf90_def_var(ncid, 'tiice', NF90_DOUBLE, (/dim_x,dim_y,dim_ice,dim_time/), id_stc_ice) call netcdf_err(error, 'DEFINING STC_ICE' ) error = nf90_put_att(ncid, id_stc_ice, "long_name", "stc_ice") call netcdf_err(error, 'DEFINING STC_ICE LONG NAME' ) From fa3fa95889057781b42b1e4c2bc2109df6c87ead Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 25 May 2023 19:59:44 +0000 Subject: [PATCH 058/107] Remove albedo records at non-land. These are not used by the model. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 123 +------------------- sorc/chgres_cube.fd/surface_target_data.F90 | 12 -- sorc/chgres_cube.fd/write_data.F90 | 105 +---------------- 3 files changed, 4 insertions(+), 236 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index d5416083e..1153a65f0 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -41,9 +41,8 @@ module surface z_c_target_grid, zm_target_grid, & soilm_tot_target_grid, lai_target_grid, & soilm_liq_target_grid, ice_temp_target_grid, & - snow_depth_at_ice_target_grid, alvsf_nl_target_grid, & - alnsf_nl_target_grid, alvwf_nl_target_grid, & - alnwf_nl_target_grid, z0_water_target_grid, & + snow_depth_at_ice_target_grid, & + z0_water_target_grid, & z0_ice_target_grid, sst_target_grid, & seaice_substrate_temp_target_grid, & snow_liq_equiv_at_ice_target_grid @@ -2488,19 +2487,6 @@ subroutine qc_check enddo enddo - if(fract_grid)then - print*,"- SET TARGET GRID ALVSF_NL AT NON-LAND." - call ESMF_FieldGet(alvsf_nl_target_grid, & - farrayPtr=data_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (seamask_ptr(i,j) == 1) data_ptr(i,j) = 0.06 ! gfs flag value at any non-land - enddo - enddo - endif - print*,"- SET TARGET GRID ALVWF AT NON-LAND." call ESMF_FieldGet(alvwf_target_grid, & farrayPtr=data_ptr, rc=rc) @@ -2514,19 +2500,6 @@ subroutine qc_check enddo enddo - if(fract_grid)then - print*,"- SET TARGET GRID ALVWF_NL AT NON-LAND." - call ESMF_FieldGet(alvwf_nl_target_grid, & - farrayPtr=data_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (seamask_ptr(i,j) == 1) data_ptr(i,j) = 0.06 ! gfs flag value at any non-land - enddo - enddo - endif - print*,"- SET TARGET GRID ALNSF AT NON-LAND." call ESMF_FieldGet(alnsf_target_grid, & farrayPtr=data_ptr, rc=rc) @@ -2540,19 +2513,6 @@ subroutine qc_check enddo enddo - if(fract_grid)then - print*,"- SET TARGET GRID ALNSF_NL AT NON-LAND." - call ESMF_FieldGet(alnsf_nl_target_grid, & - farrayPtr=data_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (seamask_ptr(i,j) == 1) data_ptr(i,j) = 0.06 ! gfs flag value at any non-land - enddo - enddo - endif - print*,"- SET TARGET GRID ALNWF AT NON-LAND." call ESMF_FieldGet(alnwf_target_grid, & farrayPtr=data_ptr, rc=rc) @@ -2566,19 +2526,6 @@ subroutine qc_check enddo enddo - if(fract_grid)then - print*,"- SET TARGET GRID ALNWF_NL AT NON-LAND." - call ESMF_FieldGet(alnwf_nl_target_grid, & - farrayPtr=data_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (seamask_ptr(i,j) == 1) data_ptr(i,j) = 0.06 ! gfs flag value at any non-land. - enddo - enddo - endif - print*,"- SET NON-LAND FLAG FOR TARGET GRID FACSF." call ESMF_FieldGet(facsf_target_grid, & farrayPtr=data_ptr, rc=rc) @@ -3359,72 +3306,6 @@ subroutine create_surface_esmf_fields target_ptr = init_val - if(fract_grid)then - print*,"- CALL FieldCreate FOR TARGET ALVSF AT NON-LAND." - alvsf_nl_target_grid = ESMF_FieldCreate(target_grid, & - typekind=ESMF_TYPEKIND_R8, & - name="alvsf_nl_target_grid", & - staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldCreate", rc) - - print*,"- INITIALIZE TARGET ALVSF AT NON-LAND." - call ESMF_FieldGet(alvsf_nl_target_grid, & - farrayPtr=target_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - - target_ptr = -1.e20 - - print*,"- CALL FieldCreate FOR TARGET ALVWF AT NON-LAND." - alvwf_nl_target_grid = ESMF_FieldCreate(target_grid, & - typekind=ESMF_TYPEKIND_R8, & - name="alvwf_nl_target_grid", & - staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldCreate", rc) - - print*,"- INITIALIZE TARGET ALVWF AT NON-LAND." - call ESMF_FieldGet(alvwf_nl_target_grid, & - farrayPtr=target_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - - target_ptr = -1.e20 - - print*,"- CALL FieldCreate FOR TARGET ALNSF AT NON-LAND." - alnsf_nl_target_grid = ESMF_FieldCreate(target_grid, & - typekind=ESMF_TYPEKIND_R8, & - name="alnsf_nl_target_grid", & - staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldCreate", rc) - - print*,"- INITIALIZE TARGET ALNSF AT NON-LAND." - call ESMF_FieldGet(alnsf_nl_target_grid, & - farrayPtr=target_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - - target_ptr = -1.e20 - - print*,"- CALL FieldCreate FOR TARGET ALNWF AT NON-LAND." - alnwf_nl_target_grid = ESMF_FieldCreate(target_grid, & - typekind=ESMF_TYPEKIND_R8, & - name="alnwf_nl_target_grid", & - staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldCreate", rc) - - print*,"- INITIALIZE TARGET ALNWF AT NON-LAND." - call ESMF_FieldGet(alnwf_nl_target_grid, & - farrayPtr=target_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - - target_ptr = -1.e20 - endif ! fract_grid - print*,"- CALL FieldCreate FOR TARGET GRID CANOPY MOISTURE CONTENT." canopy_mc_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & diff --git a/sorc/chgres_cube.fd/surface_target_data.F90 b/sorc/chgres_cube.fd/surface_target_data.F90 index 768a6612d..5a8ec5c41 100644 --- a/sorc/chgres_cube.fd/surface_target_data.F90 +++ b/sorc/chgres_cube.fd/surface_target_data.F90 @@ -15,14 +15,6 @@ module surface_target_data private ! surface fields (not including nst) - type(esmf_field), public :: alvsf_nl_target_grid - !< alvsf at non-land - type(esmf_field), public :: alvwf_nl_target_grid - !< alvwf at non-land - type(esmf_field), public :: alnsf_nl_target_grid - !< alnsf at non-land - type(esmf_field), public :: alnwf_nl_target_grid - !< alnwf at non-land type(esmf_field), public :: canopy_mc_target_grid !< Canopy moisture content. type(esmf_field), public :: f10m_target_grid @@ -164,10 +156,6 @@ subroutine cleanup_target_sfc_data call ESMF_FieldDestroy(soil_temp_target_grid, rc=rc) call ESMF_FieldDestroy(soilm_tot_target_grid, rc=rc) call ESMF_FieldDestroy(soilm_liq_target_grid, rc=rc) - if (ESMF_FieldIsCreated(alvsf_nl_target_grid)) call ESMF_FieldDestroy(alvsf_nl_target_grid, rc=rc) - if (ESMF_FieldIsCreated(alvwf_nl_target_grid)) call ESMF_FieldDestroy(alvwf_nl_target_grid, rc=rc) - if (ESMF_FieldIsCreated(alnsf_nl_target_grid)) call ESMF_FieldDestroy(alnsf_nl_target_grid, rc=rc) - if (ESMF_FieldIsCreated(alnwf_nl_target_grid)) call ESMF_FieldDestroy(alnwf_nl_target_grid, rc=rc) end subroutine cleanup_target_sfc_data diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 2c9882a91..70e7433c7 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1857,11 +1857,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) xtts_target_grid, & xzts_target_grid, & z_c_target_grid, & - zm_target_grid, & - alvsf_nl_target_grid, & - alvwf_nl_target_grid, & - alnsf_nl_target_grid, & - alnwf_nl_target_grid + zm_target_grid use static_data, only : alvsf_target_grid, & alnsf_target_grid, & @@ -1892,8 +1888,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) !integer :: id_tsfcl, id_tsea, id_sheleg, id_sheleg_ice, id_tg3 integer :: id_tsfcl, id_tsea, id_sheleg, id_tg3 integer :: id_zorl, id_zorl_land, id_zorl_ice, id_alvsf, id_alvwf - integer :: id_zorl_water, id_alvsf_nl - integer :: id_alvwf_nl, id_alnsf_nl, id_alnwf_nl + integer :: id_zorl_water integer :: id_alnsf, id_alnwf, id_vfrac integer :: id_canopy, id_f10m, id_t2m integer :: id_q2m, id_vtype, id_stype @@ -2174,17 +2169,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alvsf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALVSF COORD' ) - if(fract_grid)then - error = nf90_def_var(ncid, 'alvsf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvsf_nl) - call netcdf_err(error, 'DEFINING ALVSF_NL' ) - error = nf90_put_att(ncid, id_alvsf_nl, "long_name", "alvsf_nl") - call netcdf_err(error, 'DEFINING ALVSF_NL LONG NAME' ) - error = nf90_put_att(ncid, id_alvsf_nl, "units", "none") - call netcdf_err(error, 'DEFINING ALVSF_NL UNITS' ) - error = nf90_put_att(ncid, id_alvsf_nl, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING ALVSF_NL COORD' ) - endif - error = nf90_def_var(ncid, 'alvwf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvwf) call netcdf_err(error, 'DEFINING ALVWF' ) error = nf90_put_att(ncid, id_alvwf, "long_name", "alvwf") @@ -2194,17 +2178,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alvwf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALVWF COORD' ) - if(fract_grid)then - error = nf90_def_var(ncid, 'alvwf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvwf_nl) - call netcdf_err(error, 'DEFINING ALVWF_NL' ) - error = nf90_put_att(ncid, id_alvwf_nl, "long_name", "alvwf_nl") - call netcdf_err(error, 'DEFINING ALVWF_NL LONG NAME' ) - error = nf90_put_att(ncid, id_alvwf_nl, "units", "none") - call netcdf_err(error, 'DEFINING ALVWF_NL UNITS' ) - error = nf90_put_att(ncid, id_alvwf_nl, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING ALVWF_NL COORD' ) - endif - error = nf90_def_var(ncid, 'alnsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnsf) call netcdf_err(error, 'DEFINING ALNSF' ) error = nf90_put_att(ncid, id_alnsf, "long_name", "alnsf") @@ -2214,17 +2187,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alnsf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALNSF COORD' ) - if(fract_grid)then - error = nf90_def_var(ncid, 'alnsf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnsf_nl) - call netcdf_err(error, 'DEFINING ALNSF_NL' ) - error = nf90_put_att(ncid, id_alnsf_nl, "long_name", "alnsf_nl") - call netcdf_err(error, 'DEFINING ALNSF_NL LONG NAME' ) - error = nf90_put_att(ncid, id_alnsf_nl, "units", "none") - call netcdf_err(error, 'DEFINING ALNSF_NL UNITS' ) - error = nf90_put_att(ncid, id_alnsf_nl, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING ALNSF_NL COORD' ) - endif - error = nf90_def_var(ncid, 'alnwf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnwf) call netcdf_err(error, 'DEFINING ALNWF' ) error = nf90_put_att(ncid, id_alnwf, "long_name", "alnwf") @@ -2234,17 +2196,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_alnwf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALNWF COORD' ) - if(fract_grid)then - error = nf90_def_var(ncid, 'alnwf_nl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnwf_nl) - call netcdf_err(error, 'DEFINING ALNWF_NL' ) - error = nf90_put_att(ncid, id_alnwf_nl, "long_name", "alnwf_nl") - call netcdf_err(error, 'DEFINING ALNWF_NL LONG NAME' ) - error = nf90_put_att(ncid, id_alnwf_nl, "units", "none") - call netcdf_err(error, 'DEFINING ALNWF_NL UNITS' ) - error = nf90_put_att(ncid, id_alnwf_nl, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING ALNWF_NL COORD' ) - endif - error = nf90_def_var(ncid, 'facsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_facsf) call netcdf_err(error, 'DEFINING FACSF' ) error = nf90_put_att(ncid, id_facsf, "long_name", "facsf") @@ -2938,19 +2889,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALNSF RECORD' ) endif - if(fract_grid)then - print*,"- CALL FieldGather FOR TARGET GRID ALNSF_NL FOR TILE: ", tile - call ESMF_FieldGather(alnsf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) - if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGather", error) - - if (localpet == 0) then - dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - error = nf90_put_var( ncid, id_alnsf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING ALNSF_NL RECORD' ) - endif - endif - print*,"- CALL FieldGather FOR TARGET GRID ALNWF FOR TILE: ", tile call ESMF_FieldGather(alnwf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2962,19 +2900,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALNWF RECORD' ) endif - if(fract_grid)then - print*,"- CALL FieldGather FOR TARGET GRID ALNWF_NL FOR TILE: ", tile - call ESMF_FieldGather(alnwf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) - if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGather", error) - - if (localpet == 0) then - dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - error = nf90_put_var( ncid, id_alnwf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING ALNWF_NL RECORD' ) - endif - endif - print*,"- CALL FieldGather FOR TARGET GRID ALVSF FOR TILE: ", tile call ESMF_FieldGather(alvsf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2986,19 +2911,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALVSF RECORD' ) endif - if(fract_grid)then - print*,"- CALL FieldGather FOR TARGET GRID ALVSF_NL FOR TILE: ", tile - call ESMF_FieldGather(alvsf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) - if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGather", error) - - if (localpet == 0) then - dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - error = nf90_put_var( ncid, id_alvsf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING ALVSF_NL RECORD' ) - endif - endif - print*,"- CALL FieldGather FOR TARGET GRID ALVWF FOR TILE: ", tile call ESMF_FieldGather(alvwf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -3010,19 +2922,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING ALVWF RECORD' ) endif - if(fract_grid)then - print*,"- CALL FieldGather FOR TARGET GRID ALVWF_NL FOR TILE: ", tile - call ESMF_FieldGather(alvwf_nl_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) - if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGather", error) - - if (localpet == 0) then - dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - error = nf90_put_var( ncid, id_alvwf_nl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING ALVWF_NL RECORD' ) - endif - endif - print*,"- CALL FieldGather FOR TARGET GRID MAX VEGETATION GREENNESS FOR TILE: ", tile call ESMF_FieldGather(max_veg_greenness_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & From 4cd95f18a59e1b74d32a1c36abc8276de0c8664b Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 31 May 2023 13:58:42 +0000 Subject: [PATCH 059/107] Minor fix to coldstart file roughness records. Fixes #123. --- sorc/chgres_cube.fd/write_data.F90 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 70e7433c7..4f920ebdb 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -2142,22 +2142,22 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ZORLL COORD' ) error = nf90_def_var(ncid, 'zorli', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_ice) - call netcdf_err(error, 'DEFINING ZORL_ICE' ) - error = nf90_put_att(ncid, id_zorl_ice, "long_name", "zorl_ice") - call netcdf_err(error, 'DEFINING ZORL_ICE LONG NAME' ) + call netcdf_err(error, 'DEFINING ZORLI' ) + error = nf90_put_att(ncid, id_zorl_ice, "long_name", "zorli") + call netcdf_err(error, 'DEFINING ZORLI LONG NAME' ) error = nf90_put_att(ncid, id_zorl_ice, "units", "none") - call netcdf_err(error, 'DEFINING ZORL_ICE UNITS' ) + call netcdf_err(error, 'DEFINING ZORLI UNITS' ) error = nf90_put_att(ncid, id_zorl_ice, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING ZORL_ICE COORD' ) + call netcdf_err(error, 'DEFINING ZORLI COORD' ) error = nf90_def_var(ncid, 'zorlw', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_water) - call netcdf_err(error, 'DEFINING ZORL' ) - error = nf90_put_att(ncid, id_zorl_water, "long_name", "zorl") - call netcdf_err(error, 'DEFINING ZORL LONG NAME' ) + call netcdf_err(error, 'DEFINING ZORLW' ) + error = nf90_put_att(ncid, id_zorl_water, "long_name", "zorlw") + call netcdf_err(error, 'DEFINING ZORLW LONG NAME' ) error = nf90_put_att(ncid, id_zorl_water, "units", "none") - call netcdf_err(error, 'DEFINING ZORL UNITS' ) + call netcdf_err(error, 'DEFINING ZORLW UNITS' ) error = nf90_put_att(ncid, id_zorl_water, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING ZORL COORD' ) + call netcdf_err(error, 'DEFINING ZORLW COORD' ) ! endif error = nf90_def_var(ncid, 'alvsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvsf) From dd6fa81761dc5b06d93646b4028c8d7e009163cd Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 9 Jun 2023 19:59:47 +0000 Subject: [PATCH 060/107] Comment out processing of tg3 at ice, which is not read by the model. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 61 ++++++++++----------- sorc/chgres_cube.fd/surface_target_data.F90 | 4 +- sorc/chgres_cube.fd/write_data.F90 | 45 ++++++++------- 3 files changed, 54 insertions(+), 56 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 1153a65f0..68310e435 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -44,7 +44,6 @@ module surface snow_depth_at_ice_target_grid, & z0_water_target_grid, & z0_ice_target_grid, sst_target_grid, & - seaice_substrate_temp_target_grid, & snow_liq_equiv_at_ice_target_grid use write_data, only : write_fv3_sfc_data_netcdf @@ -2400,7 +2399,7 @@ subroutine qc_check real(esmf_kind_r8), pointer :: fice_ptr(:,:) real(esmf_kind_r8), pointer :: hice_ptr(:,:) real(esmf_kind_r8), pointer :: tg3_ptr(:,:) - real(esmf_kind_r8), pointer :: tg3_ice_ptr(:,:) +!real(esmf_kind_r8), pointer :: tg3_ice_ptr(:,:) real(esmf_kind_r8), pointer :: snod_ptr(:,:) real(esmf_kind_r8), pointer :: snol_ptr(:,:) @@ -2683,20 +2682,20 @@ subroutine qc_check if (fract_grid) then - call ESMF_FieldGet(seaice_substrate_temp_target_grid, & - farrayPtr=tg3_ice_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) > 0.0) then ! sea ice - tg3_ice_ptr(i,j) = frz_ice - else - tg3_ice_ptr(i,j) = -1.e20 - endif - enddo - enddo +! call ESMF_FieldGet(seaice_substrate_temp_target_grid, & +! farrayPtr=tg3_ice_ptr, rc=rc) +! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & +! call error_handler("IN FieldGet", rc) + +! do j = clb(2), cub(2) +! do i = clb(1), cub(1) +! if (fice_ptr(i,j) > 0.0) then ! sea ice +! tg3_ice_ptr(i,j) = frz_ice +! else +! tg3_ice_ptr(i,j) = -1.e20 +! endif +! enddo +! enddo call ESMF_FieldGet(substrate_temp_target_grid, & farrayPtr=tg3_ptr, rc=rc) @@ -3254,25 +3253,25 @@ subroutine create_surface_esmf_fields target_ptr = init_val - if (fract_grid) then +!if (fract_grid) then - print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE SUBSTRATE TEMP." - seaice_substrate_temp_target_grid = ESMF_FieldCreate(target_grid, & - typekind=ESMF_TYPEKIND_R8, & - name="seaice_substrate_temp_target_grid", & - staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldCreate", rc) +! print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE SUBSTRATE TEMP." +! seaice_substrate_temp_target_grid = ESMF_FieldCreate(target_grid, & +! typekind=ESMF_TYPEKIND_R8, & +! name="seaice_substrate_temp_target_grid", & +! staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) +! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & +! call error_handler("IN FieldCreate", rc) - print*,"- INITIALIZE TARGET sea ice substrate temp." - call ESMF_FieldGet(seaice_substrate_temp_target_grid, & - farrayPtr=target_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) +! print*,"- INITIALIZE TARGET sea ice substrate temp." +! call ESMF_FieldGet(seaice_substrate_temp_target_grid, & +! farrayPtr=target_ptr, rc=rc) +! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & +! call error_handler("IN FieldGet", rc) - target_ptr = init_val +! target_ptr = init_val - endif +!endif print*,"- CALL FieldCreate FOR TARGET GRID SRFLAG." srflag_target_grid = ESMF_FieldCreate(target_grid, & diff --git a/sorc/chgres_cube.fd/surface_target_data.F90 b/sorc/chgres_cube.fd/surface_target_data.F90 index 5a8ec5c41..18b3a111e 100644 --- a/sorc/chgres_cube.fd/surface_target_data.F90 +++ b/sorc/chgres_cube.fd/surface_target_data.F90 @@ -33,7 +33,7 @@ module surface_target_data !< Sea ice fraction. type(esmf_field), public :: seaice_skin_temp_target_grid !< Sea ice skin temperature. - type(esmf_field), public :: seaice_substrate_temp_target_grid +!type(esmf_field), public :: seaice_substrate_temp_target_grid !< Sea ice substrate temperature. type(esmf_field), public :: skin_temp_target_grid !< Skin temperature/sst. @@ -144,7 +144,7 @@ subroutine cleanup_target_sfc_data call ESMF_FieldDestroy(seaice_fract_target_grid, rc=rc) call ESMF_FieldDestroy(seaice_depth_target_grid, rc=rc) call ESMF_FieldDestroy(seaice_skin_temp_target_grid, rc=rc) - if (ESMF_FieldIsCreated(seaice_substrate_temp_target_grid)) call ESMF_FieldDestroy(seaice_substrate_temp_target_grid, rc=rc) +!if (ESMF_FieldIsCreated(seaice_substrate_temp_target_grid)) call ESMF_FieldDestroy(seaice_substrate_temp_target_grid, rc=rc) call ESMF_FieldDestroy(srflag_target_grid, rc=rc) call ESMF_FieldDestroy(skin_temp_target_grid, rc=rc) if (ESMF_FieldIsCreated(sst_target_grid)) call ESMF_FieldDestroy(sst_target_grid, rc=rc) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 4f920ebdb..190efcb0f 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1821,7 +1821,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) seaice_depth_target_grid, & seaice_fract_target_grid, & seaice_skin_temp_target_grid, & - seaice_substrate_temp_target_grid, & skin_temp_target_grid, & sst_target_grid, & soil_temp_target_grid, & @@ -1884,7 +1883,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: error, i, ncid, tile integer :: id_x, id_y, id_lsoil, id_ice integer :: id_slmsk, id_time - integer :: id_lat, id_lon, id_tg3_ice + integer :: id_lat, id_lon !integer :: id_tsfcl, id_tsea, id_sheleg, id_sheleg_ice, id_tg3 integer :: id_tsfcl, id_tsea, id_sheleg, id_tg3 integer :: id_zorl, id_zorl_land, id_zorl_ice, id_alvsf, id_alvwf @@ -2110,16 +2109,16 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_tg3, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TG3 COORD' ) - if(fract_grid)then - error = nf90_def_var(ncid, 'tg3_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3_ice) - call netcdf_err(error, 'DEFINING TG3_ICE' ) - error = nf90_put_att(ncid, id_tg3_ice, "long_name", "tg3_ice") - call netcdf_err(error, 'DEFINING TG3_ICE LONG NAME' ) - error = nf90_put_att(ncid, id_tg3_ice, "units", "none") - call netcdf_err(error, 'DEFINING TG3_ICE UNITS' ) - error = nf90_put_att(ncid, id_tg3_ice, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING TG3_ICE COORD' ) - endif +! if(fract_grid)then +! error = nf90_def_var(ncid, 'tg3_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3_ice) +! call netcdf_err(error, 'DEFINING TG3_ICE' ) +! error = nf90_put_att(ncid, id_tg3_ice, "long_name", "tg3_ice") +! call netcdf_err(error, 'DEFINING TG3_ICE LONG NAME' ) +! error = nf90_put_att(ncid, id_tg3_ice, "units", "none") +! call netcdf_err(error, 'DEFINING TG3_ICE UNITS' ) +! error = nf90_put_att(ncid, id_tg3_ice, "coordinates", "geolon geolat") +! call netcdf_err(error, 'DEFINING TG3_ICE COORD' ) +! endif ! if(.not.fract_grid)then error = nf90_def_var(ncid, 'zorl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl) @@ -2841,20 +2840,20 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SUBSTRATE TEMPERATURE RECORD' ) endif - if(fract_grid) then +! if(fract_grid) then - print*,"- CALL FieldGather FOR TARGET GRID SEAICE SUBSTRATE TEMPERATURE FOR TILE: ", tile - call ESMF_FieldGather(seaice_substrate_temp_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) - if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGather", error) +! print*,"- CALL FieldGather FOR TARGET GRID SEAICE SUBSTRATE TEMPERATURE FOR TILE: ", tile +! call ESMF_FieldGather(seaice_substrate_temp_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) +! if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & +! call error_handler("IN FieldGather", error) - if (localpet == 0) then - dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - error = nf90_put_var( ncid, id_tg3_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING SEAICE SUBSTRATE TEMPERATURE RECORD' ) - endif +! if (localpet == 0) then +! dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) +! error = nf90_put_var( ncid, id_tg3_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) +! call netcdf_err(error, 'WRITING SEAICE SUBSTRATE TEMPERATURE RECORD' ) +! endif - endif +! endif print*,"- CALL FieldGather FOR TARGET GRID FACSF FOR TILE: ", tile call ESMF_FieldGather(facsf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) From 689b278cacb53582c223369dcca653cd9391c93e Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 12 Jun 2023 19:33:45 +0000 Subject: [PATCH 061/107] Comment out write of zorl at land, which is not used by the model. Fixes #123. --- sorc/chgres_cube.fd/write_data.F90 | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 190efcb0f..bcb6ed06d 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -2131,14 +2131,14 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ZORL COORD' ) ! else - error = nf90_def_var(ncid, 'zorll', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_land) - call netcdf_err(error, 'DEFINING ZORLL' ) - error = nf90_put_att(ncid, id_zorl_land, "long_name", "zorll") - call netcdf_err(error, 'DEFINING ZORLL LONG NAME' ) - error = nf90_put_att(ncid, id_zorl_land, "units", "none") - call netcdf_err(error, 'DEFINING ZORLL UNITS' ) - error = nf90_put_att(ncid, id_zorl_land, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING ZORLL COORD' ) +! error = nf90_def_var(ncid, 'zorll', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_land) +! call netcdf_err(error, 'DEFINING ZORLL' ) +! error = nf90_put_att(ncid, id_zorl_land, "long_name", "zorll") +! call netcdf_err(error, 'DEFINING ZORLL LONG NAME' ) +! error = nf90_put_att(ncid, id_zorl_land, "units", "none") +! call netcdf_err(error, 'DEFINING ZORLL UNITS' ) +! error = nf90_put_att(ncid, id_zorl_land, "coordinates", "geolon geolat") +! call netcdf_err(error, 'DEFINING ZORLL COORD' ) error = nf90_def_var(ncid, 'zorli', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_ice) call netcdf_err(error, 'DEFINING ZORLI' ) @@ -2736,16 +2736,16 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if(fract_grid)then - print*,"- CALL FieldGather FOR TARGET GRID Z0_land FOR TILE: ", tile - call ESMF_FieldGather(z0_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) - if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGather", error) +! print*,"- CALL FieldGather FOR TARGET GRID Z0_land FOR TILE: ", tile +! call ESMF_FieldGather(z0_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) +! if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & +! call error_handler("IN FieldGather", error) - if (localpet == 0) then - dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - error = nf90_put_var( ncid, id_zorl_land, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING Z0_LAND RECORD' ) - endif +! if (localpet == 0) then +! dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) +! error = nf90_put_var( ncid, id_zorl_land, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) +! call netcdf_err(error, 'WRITING Z0_LAND RECORD' ) +! endif print*,"- CALL FieldGather FOR TARGET GRID Z0_ICE FOR TILE: ", tile call ESMF_FieldGather(z0_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) From 570cc82f69dce1be58c6bd800e970af500a661a1 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 14 Jun 2023 17:22:08 +0000 Subject: [PATCH 062/107] Remove write of composite snow. Add write of snow at land and ice. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 24 ++--- sorc/chgres_cube.fd/write_data.F90 | 158 +++++++++++++++++------------ 2 files changed, 104 insertions(+), 78 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 68310e435..5b2ae7356 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2746,8 +2746,8 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 0.0) then - snol_ptr(i,j) = -1.e20 - snod_ptr(i,j) = -1.e20 + snol_ptr(i,j) = 1.e20 + snod_ptr(i,j) = 1.e20 end if enddo enddo @@ -2764,11 +2764,11 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) then ! not land - if (fice_ptr(i,j) > 0.0) then - data_ptr(i,j) = snod_ptr(i,j) - else - data_ptr(i,j) = -1.e20 - endif +! if (fice_ptr(i,j) > 0.0) then +! data_ptr(i,j) = snod_ptr(i,j) +! else + data_ptr(i,j) = 1.e20 +! endif end if enddo enddo @@ -2792,11 +2792,11 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) then ! not land - if (fice_ptr(i,j) > 0.0) then - data_ptr(i,j) = snol_ptr(i,j) - else - data_ptr(i,j) = -1.e20 - endif + ! if (fice_ptr(i,j) > 0.0) then + ! data_ptr(i,j) = snol_ptr(i,j) + ! else + data_ptr(i,j) = 1.e20 + ! endif end if enddo enddo diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index bcb6ed06d..47930cfd4 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1830,8 +1830,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) srflag_target_grid, & snow_liq_equiv_target_grid, & snow_depth_target_grid, & -! snow_liq_equiv_at_ice_target_grid, & -! snow_depth_at_ice_target_grid, & + snow_liq_equiv_at_ice_target_grid, & + snow_depth_at_ice_target_grid, & t2m_target_grid, & tprcp_target_grid, & ustar_target_grid, & @@ -1884,8 +1884,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_x, id_y, id_lsoil, id_ice integer :: id_slmsk, id_time integer :: id_lat, id_lon -!integer :: id_tsfcl, id_tsea, id_sheleg, id_sheleg_ice, id_tg3 - integer :: id_tsfcl, id_tsea, id_sheleg, id_tg3 + integer :: id_tsfcl, id_tsea, id_sheleg, id_sheleg_ice, id_sheleg_land, id_tg3 +!integer :: id_tsfcl, id_tsea, id_sheleg, id_tg3 integer :: id_zorl, id_zorl_land, id_zorl_ice, id_alvsf, id_alvwf integer :: id_zorl_water integer :: id_alnsf, id_alnwf, id_vfrac @@ -1894,8 +1894,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_facsf, id_facwf, id_uustar integer :: id_ffmm, id_ffhh, id_hice integer :: id_fice, id_tisfc, id_tprcp -!integer :: id_srflag, id_snwdph, id_snwdph_ice, id_shdmin - integer :: id_srflag, id_snwdph, id_shdmin + integer :: id_srflag, id_snwdph, id_snwdph_ice, id_snwdph_land, id_shdmin +!integer :: id_srflag, id_snwdph, id_shdmin integer :: id_shdmax, id_slope, id_snoalb integer :: id_lai, id_stc_ice integer :: id_stc, id_smc, id_slc @@ -2080,25 +2080,34 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_tsea, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TSEA COORD' ) - error = nf90_def_var(ncid, 'sheleg', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg) - call netcdf_err(error, 'DEFINING SHELEG' ) - error = nf90_put_att(ncid, id_sheleg, "long_name", "sheleg") - call netcdf_err(error, 'DEFINING SHELEG LONG NAME' ) - error = nf90_put_att(ncid, id_sheleg, "units", "none") - call netcdf_err(error, 'DEFINING SHELEG UNITS' ) - error = nf90_put_att(ncid, id_sheleg, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING SHELEG COORD' ) +! error = nf90_def_var(ncid, 'sheleg', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg) +! call netcdf_err(error, 'DEFINING SHELEG' ) +! error = nf90_put_att(ncid, id_sheleg, "long_name", "sheleg") +! call netcdf_err(error, 'DEFINING SHELEG LONG NAME' ) +! error = nf90_put_att(ncid, id_sheleg, "units", "none") +! call netcdf_err(error, 'DEFINING SHELEG UNITS' ) +! error = nf90_put_att(ncid, id_sheleg, "coordinates", "geolon geolat") +! call netcdf_err(error, 'DEFINING SHELEG COORD' ) -! if(fract_grid)then -! error = nf90_def_var(ncid, 'sheleg_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_ice) -! call netcdf_err(error, 'DEFINING SHELEG AT ICE' ) -! error = nf90_put_att(ncid, id_sheleg_ice, "long_name", "sheleg_ice") -! call netcdf_err(error, 'DEFINING SHELEG ICE LONG NAME' ) -! error = nf90_put_att(ncid, id_sheleg_ice, "units", "none") -! call netcdf_err(error, 'DEFINING SHELEG AT ICE UNITS' ) -! error = nf90_put_att(ncid, id_sheleg_ice, "coordinates", "geolon geolat") -! call netcdf_err(error, 'DEFINING SHELEG AT ICE COORD' ) -! endif + if(fract_grid)then + error = nf90_def_var(ncid, 'weasdi', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_ice) + call netcdf_err(error, 'DEFINING SHELEG AT ICE' ) + error = nf90_put_att(ncid, id_sheleg_ice, "long_name", "sheleg_ice") + call netcdf_err(error, 'DEFINING SHELEG ICE LONG NAME' ) + error = nf90_put_att(ncid, id_sheleg_ice, "units", "none") + call netcdf_err(error, 'DEFINING SHELEG AT ICE UNITS' ) + error = nf90_put_att(ncid, id_sheleg_ice, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING SHELEG AT ICE COORD' ) + + error = nf90_def_var(ncid, 'weasdl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_land) + call netcdf_err(error, 'DEFINING SHELEG AT ICE' ) + error = nf90_put_att(ncid, id_sheleg_land, "long_name", "sheleg_land") + call netcdf_err(error, 'DEFINING SHELEG ICE LONG NAME' ) + error = nf90_put_att(ncid, id_sheleg_land, "units", "none") + call netcdf_err(error, 'DEFINING SHELEG AT ICE UNITS' ) + error = nf90_put_att(ncid, id_sheleg_land, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING SHELEG AT ICE COORD' ) + endif error = nf90_def_var(ncid, 'tg3', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3) call netcdf_err(error, 'DEFINING TG3' ) @@ -2348,25 +2357,34 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_srflag, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SRFLAG COORD' ) - error = nf90_def_var(ncid, 'snwdph', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph) - call netcdf_err(error, 'DEFINING SNWDPH' ) - error = nf90_put_att(ncid, id_snwdph, "long_name", "snwdph") - call netcdf_err(error, 'DEFINING SNWDPH LONG NAME' ) - error = nf90_put_att(ncid, id_snwdph, "units", "none") - call netcdf_err(error, 'DEFINING SNWDPH UNITS' ) - error = nf90_put_att(ncid, id_snwdph, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING SNWDPH COORD' ) +! error = nf90_def_var(ncid, 'snwdph', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph) +! call netcdf_err(error, 'DEFINING SNWDPH' ) +! error = nf90_put_att(ncid, id_snwdph, "long_name", "snwdph") +! call netcdf_err(error, 'DEFINING SNWDPH LONG NAME' ) +! error = nf90_put_att(ncid, id_snwdph, "units", "none") +! call netcdf_err(error, 'DEFINING SNWDPH UNITS' ) +! error = nf90_put_att(ncid, id_snwdph, "coordinates", "geolon geolat") +! call netcdf_err(error, 'DEFINING SNWDPH COORD' ) -! if(fract_grid)then -! error = nf90_def_var(ncid, 'snwdph_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph_ice) -! call netcdf_err(error, 'DEFINING SNWDPH AT ICE' ) -! error = nf90_put_att(ncid, id_snwdph_ice, "long_name", "snwdph_ice") -! call netcdf_err(error, 'DEFINING SNWDPH AT ICE LONG NAME' ) -! error = nf90_put_att(ncid, id_snwdph_ice, "units", "none") -! call netcdf_err(error, 'DEFINING SNWDPH AT ICE UNITS' ) -! error = nf90_put_att(ncid, id_snwdph_ice, "coordinates", "geolon geolat") -! call netcdf_err(error, 'DEFINING SNWDPH AT ICE COORD' ) -! endif + if(fract_grid)then + error = nf90_def_var(ncid, 'snodi', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph_ice) + call netcdf_err(error, 'DEFINING SNWDPH AT ICE' ) + error = nf90_put_att(ncid, id_snwdph_ice, "long_name", "snwdph_ice") + call netcdf_err(error, 'DEFINING SNWDPH AT ICE LONG NAME' ) + error = nf90_put_att(ncid, id_snwdph_ice, "units", "none") + call netcdf_err(error, 'DEFINING SNWDPH AT ICE UNITS' ) + error = nf90_put_att(ncid, id_snwdph_ice, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING SNWDPH AT ICE COORD' ) + + error = nf90_def_var(ncid, 'snodl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph_land) + call netcdf_err(error, 'DEFINING SNWDPH AT ICE' ) + error = nf90_put_att(ncid, id_snwdph_land, "long_name", "snwdph_land") + call netcdf_err(error, 'DEFINING SNWDPH AT ICE LONG NAME' ) + error = nf90_put_att(ncid, id_snwdph_land, "units", "none") + call netcdf_err(error, 'DEFINING SNWDPH AT ICE UNITS' ) + error = nf90_put_att(ncid, id_snwdph_land, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING SNWDPH AT ICE COORD' ) + endif error = nf90_def_var(ncid, 'shdmin', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_shdmin) call netcdf_err(error, 'DEFINING SHDMIN' ) @@ -2669,22 +2687,27 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - error = nf90_put_var( ncid, id_sheleg, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + error = nf90_put_var( ncid, id_sheleg_land, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING SNOW LIQ EQUIV RECORD' ) +! dum2d(:,:) = 1.e20 +! error = nf90_put_var( ncid, id_sheleg, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) +! call netcdf_err(error, 'WRITING SNOW LIQ EQUIV RECORD' ) endif -! if(fract_grid) then -! print*,"- CALL FieldGather FOR TARGET GRID SNOW LIQ EQUIV at ice FOR TILE: ", tile -! call ESMF_FieldGather(snow_liq_equiv_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) -! if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldGather", error) + if(fract_grid) then -! if (localpet == 0) then -! dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) -! error = nf90_put_var( ncid, id_sheleg_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) -! call netcdf_err(error, 'WRITING SNOW LIQ EQUIV at ice RECORD' ) -! endif -! endif + print*,"- CALL FieldGather FOR TARGET GRID SNOW LIQ EQUIV at ice FOR TILE: ", tile + call ESMF_FieldGather(snow_liq_equiv_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) + + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_sheleg_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING SNOW LIQ EQUIV at ice RECORD' ) + endif + + endif print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH FOR TILE: ", tile call ESMF_FieldGather(snow_depth_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) @@ -2693,23 +2716,26 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - error = nf90_put_var( ncid, id_snwdph, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + error = nf90_put_var( ncid, id_snwdph_land, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING SNWDPH RECORD' ) +! dum2d(:,:) = 1.e20 +! error = nf90_put_var( ncid, id_snwdph, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) +! call netcdf_err(error, 'WRITING SNWDPH RECORD' ) endif -! if (fract_grid)then -! print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH at ice FOR TILE: ", tile -! call ESMF_FieldGather(snow_depth_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) -! if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldGather", error) + if (fract_grid)then + print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH at ice FOR TILE: ", tile + call ESMF_FieldGather(snow_depth_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGather", error) -! if (localpet == 0) then -! dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) -! error = nf90_put_var( ncid, id_snwdph_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) -! call netcdf_err(error, 'WRITING SNWDPH at ice RECORD' ) -! endif + if (localpet == 0) then + dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) + error = nf90_put_var( ncid, id_snwdph_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING SNWDPH at ice RECORD' ) + endif -! endif + endif print*,"- CALL FieldGather FOR TARGET GRID SLOPE TYPE FOR TILE: ", tile call ESMF_FieldGather(slope_type_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) From c6c0fcbe11ba9a476a82436126bee5a5f678a430 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 16 Jun 2023 13:14:38 +0000 Subject: [PATCH 063/107] Comment out write of composite roughness. Fixes #123. --- sorc/chgres_cube.fd/write_data.F90 | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 47930cfd4..5baf150b5 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -2130,14 +2130,14 @@ subroutine write_fv3_sfc_data_netcdf(localpet) ! endif ! if(.not.fract_grid)then - error = nf90_def_var(ncid, 'zorl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl) - call netcdf_err(error, 'DEFINING ZORL' ) - error = nf90_put_att(ncid, id_zorl, "long_name", "zorl") - call netcdf_err(error, 'DEFINING ZORL LONG NAME' ) - error = nf90_put_att(ncid, id_zorl, "units", "none") - call netcdf_err(error, 'DEFINING ZORL UNITS' ) - error = nf90_put_att(ncid, id_zorl, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING ZORL COORD' ) +! error = nf90_def_var(ncid, 'zorl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl) +! call netcdf_err(error, 'DEFINING ZORL' ) +! error = nf90_put_att(ncid, id_zorl, "long_name", "zorl") +! call netcdf_err(error, 'DEFINING ZORL LONG NAME' ) +! error = nf90_put_att(ncid, id_zorl, "units", "none") +! call netcdf_err(error, 'DEFINING ZORL UNITS' ) +! error = nf90_put_att(ncid, id_zorl, "coordinates", "geolon geolat") +! call netcdf_err(error, 'DEFINING ZORL COORD' ) ! else ! error = nf90_def_var(ncid, 'zorll', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_land) @@ -2748,17 +2748,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SLOPE RECORD' ) endif - print*,"- CALL FieldGather FOR TARGET GRID Z0 FOR TILE: ", tile - call ESMF_FieldGather(z0_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) - if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGather", error) +! print*,"- CALL FieldGather FOR TARGET GRID Z0 FOR TILE: ", tile +! call ESMF_FieldGather(z0_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) +! if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & +! call error_handler("IN FieldGather", error) - if (localpet == 0) then +! if (localpet == 0) then ! dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - dum2d(:,:) = 1.e20 - error = nf90_put_var( ncid, id_zorl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING Z0 RECORD' ) - endif +! dum2d(:,:) = 1.e20 +! error = nf90_put_var( ncid, id_zorl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) +! call netcdf_err(error, 'WRITING Z0 RECORD' ) +! endif if(fract_grid)then From 395bbe5d3b04faaf0935365dc664a97dd74d8af6 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 22 Jun 2023 20:28:00 +0000 Subject: [PATCH 064/107] Modify logic to output the surface specific records regardless of whether processing a fractional or non-fractional grid. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 297 ++++++++++++++++------------- sorc/chgres_cube.fd/write_data.F90 | 58 +++--- 2 files changed, 190 insertions(+), 165 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 5b2ae7356..66e380a20 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -833,15 +833,15 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleCreate", rc) - if (fract_grid) then +!if (fract_grid) then call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_at_ice_target_grid, & snow_liq_equiv_at_ice_target_grid, seaice_skin_temp_target_grid, & ice_temp_target_grid/), rc=rc) - else - call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_target_grid, & - snow_liq_equiv_target_grid, seaice_skin_temp_target_grid, & - soil_temp_target_grid/), rc=rc) - endif +!else +! call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_target_grid, & +! snow_liq_equiv_target_grid, seaice_skin_temp_target_grid, & +! soil_temp_target_grid/), rc=rc) +!endif if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) @@ -938,7 +938,7 @@ subroutine interp(localpet) isrctermprocessing = 1 print*,"- CALL FieldRegridStore for water fields." - if(fract_grid)then +!if(fract_grid)then call ESMF_FieldRegridStore(skin_temp_input_grid, & sst_target_grid, & srcmaskvalues=(/0/), & @@ -950,19 +950,19 @@ subroutine interp(localpet) routehandle=regrid_water, & regridmethod=method, & unmappedDstList=unmapped_ptr, rc=rc) - else - call ESMF_FieldRegridStore(skin_temp_input_grid, & - skin_temp_target_grid, & - srcmaskvalues=(/0/), & - dstmaskvalues=(/0/), & - polemethod=ESMF_POLEMETHOD_NONE, & - srctermprocessing=isrctermprocessing, & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & - normtype=ESMF_NORMTYPE_FRACAREA, & - routehandle=regrid_water, & - regridmethod=method, & - unmappedDstList=unmapped_ptr, rc=rc) - endif +!else +!call ESMF_FieldRegridStore(skin_temp_input_grid, & +! skin_temp_target_grid, & +! srcmaskvalues=(/0/), & +! dstmaskvalues=(/0/), & +! polemethod=ESMF_POLEMETHOD_NONE, & +! srctermprocessing=isrctermprocessing, & +! unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & +! normtype=ESMF_NORMTYPE_FRACAREA, & +! routehandle=regrid_water, & +! regridmethod=method, & +! unmappedDstList=unmapped_ptr, rc=rc) +!endif if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldRegridStore", rc) @@ -973,11 +973,11 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleCreate", rc) - if(fract_grid)then +!if(fract_grid)then call ESMF_FieldBundleAdd(bundle_water_target, (/sst_target_grid, z0_water_target_grid/), rc=rc) - else - call ESMF_FieldBundleAdd(bundle_water_target, (/skin_temp_target_grid, z0_target_grid/), rc=rc) - endif +!else +!call ESMF_FieldBundleAdd(bundle_water_target, (/skin_temp_target_grid, z0_target_grid/), rc=rc) +!endif if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) @@ -2290,7 +2290,18 @@ subroutine roughness if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - if(fract_grid)then + print*,"- CALL FieldGet FOR TARGET GRID Z0 WATER." + call ESMF_FieldGet(z0_water_target_grid, & + farrayPtr=data_ptr3, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + + print*,"- CALL FieldGet FOR TARGET SEA MASK." + call ESMF_FieldGet(seamask_target_grid, & + farrayPtr=seamask_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + call error_handler("IN FieldGet", rc) + print*,"- CALL FieldGet FOR TARGET GRID Z0 ICE." call ESMF_FieldGet(z0_ice_target_grid, & @@ -2308,6 +2319,8 @@ subroutine roughness enddo enddo + if(fract_grid)then + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 1) then @@ -2318,17 +2331,17 @@ subroutine roughness enddo enddo - print*,"- CALL FieldGet FOR TARGET GRID Z0 WATER." - call ESMF_FieldGet(z0_water_target_grid, & - farrayPtr=data_ptr3, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) +! print*,"- CALL FieldGet FOR TARGET GRID Z0 WATER." +! call ESMF_FieldGet(z0_water_target_grid, & +! farrayPtr=data_ptr3, rc=rc) +! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & +! call error_handler("IN FieldGet", rc) - print*,"- CALL FieldGet FOR TARGET SEA MASK." - call ESMF_FieldGet(seamask_target_grid, & - farrayPtr=seamask_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) +! print*,"- CALL FieldGet FOR TARGET SEA MASK." +! call ESMF_FieldGet(seamask_target_grid, & +! farrayPtr=seamask_ptr, rc=rc) +! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & +! call error_handler("IN FieldGet", rc) do j = clb(2), cub(2) do i = clb(1), cub(1) @@ -2344,10 +2357,10 @@ subroutine roughness !cfract grids need to preserve original landmask_target. do j = clb(2), cub(2) do i = clb(1), cub(1) - if (fice_ptr(i,j) > 0.0) then - data_ptr(i,j) = 1.0 - elseif (landmask_ptr(i,j) == 1) then - data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0 + if (fice_ptr(i,j) > 0.0 .or. seamask_ptr(i,j) == 0) then + data_ptr3(i,j) = 1.e20 +! elseif (landmask_ptr(i,j) == 1) then +! data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0 endif enddo enddo @@ -2411,13 +2424,13 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - if (fract_grid) then +!if (fract_grid) then print*,"- CALL FieldGet FOR TARGET GRID SEA MASK." call ESMF_FieldGet(seamask_target_grid, & farrayPtr=seamask_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - endif +!endif print*,"- CALL FieldGet FOR TARGET GRID SEA ICE FRACTION." call ESMF_FieldGet(seaice_fract_target_grid, & @@ -2481,8 +2494,8 @@ subroutine qc_check !cfract That means points where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value +! if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2494,8 +2507,8 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value +! if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2507,8 +2520,8 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value +! if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2520,8 +2533,8 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.06 ! gfs physics flag value - if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value +! if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2633,7 +2646,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - if(fract_grid)then +!if(fract_grid)then do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) > 0.0) then @@ -2645,21 +2658,21 @@ subroutine qc_check endif enddo enddo - else - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) > 0.0) then - skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + & - ( (1.0 - fice_ptr(i,j)) * frz_ice ) - else - seaice_skint_ptr(i,j) = skint_ptr(i,j) - hice_ptr(i,j) = 0.0 - endif - enddo - enddo - endif +!else +!do j = clb(2), cub(2) +!do i = clb(1), cub(1) +! if (fice_ptr(i,j) > 0.0) then +! skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + & +! ( (1.0 - fice_ptr(i,j)) * frz_ice ) +! else +! seaice_skint_ptr(i,j) = skint_ptr(i,j) +! hice_ptr(i,j) = 0.0 +! endif +!enddo +!enddo +!endif - if (fract_grid) then +!if (fract_grid) then print*,"- SET TARGET GRID SST FLAG VALUE." @@ -2668,6 +2681,8 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) + if (fract_grid) then + do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 1.0_esmf_kind_r8 .or. seamask_ptr(i,j) == 0.0) then @@ -2676,11 +2691,21 @@ subroutine qc_check enddo enddo + else + + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) > 0.0 .or. seamask_ptr(i,j) == 0.0) then + data_ptr(i,j) = 1.e20 + endif + enddo + enddo + endif print*,"- SET TARGET GRID SUBSTRATE TEMP AT ICE." - if (fract_grid) then +!if (fract_grid) then ! call ESMF_FieldGet(seaice_substrate_temp_target_grid, & ! farrayPtr=tg3_ice_ptr, rc=rc) @@ -2710,26 +2735,26 @@ subroutine qc_check enddo enddo - else +!else - call ESMF_FieldGet(substrate_temp_target_grid, & - farrayPtr=tg3_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) +!call ESMF_FieldGet(substrate_temp_target_grid, & +! farrayPtr=tg3_ptr, rc=rc) +!if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & +! call error_handler("IN FieldGet", rc) - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) > 0.0) then ! sea ice - tg3_ptr(i,j) = frz_ice - elseif (landmask_ptr(i,j) == 0) then ! open water flag value. - tg3_ptr(i,j) = skint_ptr(i,j) - endif - enddo - enddo +!do j = clb(2), cub(2) +!do i = clb(1), cub(1) +! if (fice_ptr(i,j) > 0.0) then ! sea ice +! tg3_ptr(i,j) = frz_ice +! elseif (landmask_ptr(i,j) == 0) then ! open water flag value. +! tg3_ptr(i,j) = skint_ptr(i,j) +! endif +!enddo +!enddo - endif +!endif - if (fract_grid) then +!if (fract_grid) then print*,"- SET MISSING FLAG AT TARGET GRID SNOW DEPTH AT ICE." call ESMF_FieldGet(snow_depth_at_ice_target_grid, & @@ -2752,7 +2777,7 @@ subroutine qc_check enddo enddo - endif +!endif print*,"- ZERO OUT TARGET GRID SNOW DEPTH AT OPEN WATER." call ESMF_FieldGet(snow_depth_target_grid, & @@ -2760,7 +2785,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - if (fract_grid) then +!if (fract_grid) then do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) then ! not land @@ -2772,15 +2797,15 @@ subroutine qc_check end if enddo enddo - else - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then - data_ptr(i,j) = 0.0 - end if - enddo - enddo - endif +!else +! do j = clb(2), cub(2) +! do i = clb(1), cub(1) +! if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then +! data_ptr(i,j) = 0.0 +! end if +! enddo +! enddo +!endif print*,"- ZERO OUT TARGET GRID SNOW LIQ AT OPEN WATER." call ESMF_FieldGet(snow_liq_equiv_target_grid, & @@ -2788,7 +2813,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - if (fract_grid) then +!if (fract_grid) then do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) then ! not land @@ -2800,15 +2825,15 @@ subroutine qc_check end if enddo enddo - else - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then - data_ptr(i,j) = 0.0 - end if - enddo - enddo - endif +!else +! do j = clb(2), cub(2) +! do i = clb(1), cub(1) +! if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then +! data_ptr(i,j) = 0.0 +! end if +! enddo +! enddo +!endif print*,"- SET NON-LAND FLAG VALUE FOR TARGET GRID TOTAL SOIL MOISTURE." call ESMF_FieldGet(soilm_tot_target_grid, & @@ -2822,7 +2847,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - if (fract_grid) then +!if (fract_grid) then do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0 .or. & @@ -2832,17 +2857,17 @@ subroutine qc_check endif enddo enddo - else - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) > 0.0 .or. landmask_ptr(i,j) == 0 .or. & - nint(veg_type_ptr(i,j)) == veg_type_landice_target) then - soilmt_ptr(i,j,:) = 1.0 - soilml_ptr(i,j,:) = 1.0 - endif - enddo - enddo - endif +!else +! do j = clb(2), cub(2) +! do i = clb(1), cub(1) +! if (fice_ptr(i,j) > 0.0 .or. landmask_ptr(i,j) == 0 .or. & +! nint(veg_type_ptr(i,j)) == veg_type_landice_target) then +! soilmt_ptr(i,j,:) = 1.0 +! soilml_ptr(i,j,:) = 1.0 +! endif +! enddo +! enddo +!endif print*,"- SET OPEN WATER FLAG FOR TARGET GRID SOIL TEMPERATURE." call ESMF_FieldGet(soil_temp_target_grid, & @@ -2850,7 +2875,7 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - if (fract_grid) then +!if (fract_grid) then do j = clb(2), cub(2) do i = clb(1), cub(1) @@ -2874,19 +2899,19 @@ subroutine qc_check enddo enddo - else +!else - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then - data3d_ptr(i,j,:) = skint_ptr(i,j) ! open water flag value. - endif - enddo - enddo +!do j = clb(2), cub(2) +!do i = clb(1), cub(1) +! if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then +! data3d_ptr(i,j,:) = skint_ptr(i,j) ! open water flag value. +! endif +!enddo +!enddo - endif +!endif - if (fract_grid) then ! set flag value at non-land +!if (fract_grid) then ! set flag value at non-land do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0) then @@ -2894,7 +2919,7 @@ subroutine qc_check endif enddo enddo - endif +!endif return @@ -3134,7 +3159,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val - if (fract_grid) then +!if (fract_grid) then print*,"- CALL FieldCreate FOR TARGET GRID SNOW LIQ EQUIV AT SEA ICE." snow_liq_equiv_at_ice_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3151,7 +3176,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val - endif ! fractional grid +!endif ! fractional grid print*,"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH." snow_depth_target_grid = ESMF_FieldCreate(target_grid, & @@ -3169,7 +3194,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val - if (fract_grid) then +!if (fract_grid) then print*,"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH AT SEA ICE." snow_depth_at_ice_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3185,7 +3210,7 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr = init_val - endif +!endif print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE FRACTION." seaice_fract_target_grid = ESMF_FieldCreate(target_grid, & @@ -3219,7 +3244,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val - if(fract_grid)then +!if(fract_grid)then print*,"- CALL FieldCreate FOR TARGET GRID sst." sst_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3235,7 +3260,7 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr = init_val - endif +!endif print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE SKIN TEMP." seaice_skin_temp_target_grid = ESMF_FieldCreate(target_grid, & @@ -3353,7 +3378,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val - if (fract_grid)then +!if (fract_grid)then print*,"- CALL FieldCreate FOR TARGET GRID Z0_ICE." z0_ice_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3385,7 +3410,7 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr = init_val - endif +!endif print*,"- CALL FieldCreate FOR INTERPOLATED TARGET GRID TERRAIN." terrain_from_input_grid = ESMF_FieldCreate(target_grid, & @@ -3419,7 +3444,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val - if(fract_grid)then +!if(fract_grid)then print*,"- CALL FieldCreate FOR TARGET GRID sea ice column TEMPERATURE." ice_temp_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3437,7 +3462,7 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr_3d = init_val - endif +!endif print*,"- CALL FieldCreate FOR TARGET GRID SOIL TEMPERATURE." soil_temp_target_grid = ESMF_FieldCreate(target_grid, & diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 5baf150b5..98d667130 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1982,10 +1982,10 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING YAXIS DIMENSION' ) error = nf90_def_dim(ncid, 'zaxis_1', lsoil_target, dim_lsoil) call netcdf_err(error, 'DEFINING ZAXIS DIMENSION' ) - if (fract_grid) then +! if (fract_grid) then error = nf90_def_dim(ncid, 'zaxis_2', 2, dim_ice) call netcdf_err(error, 'DEFINING ZAXIS2 DIMENSION' ) - endif +! endif error = nf90_def_dim(ncid, 'Time', 1, dim_time) call netcdf_err(error, 'DEFINING TIME DIMENSION' ) @@ -2017,7 +2017,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_lsoil, "cartesian_axis", "Z") call netcdf_err(error, 'WRITING ZAXIS_1 FIELD' ) - if (fract_grid) then +! if (fract_grid) then error = nf90_def_var(ncid, 'zaxis_2', NF90_FLOAT, (/dim_ice/), id_ice) call netcdf_err(error, 'DEFINING ZAXIS_2 FIELD' ) error = nf90_put_att(ncid, id_ice, "long_name", "zaxis_2") @@ -2026,7 +2026,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ZAXIS_2 UNITS' ) error = nf90_put_att(ncid, id_ice, "cartesian_axis", "Z") call netcdf_err(error, 'WRITING ZAXIS_2 FIELD' ) - endif +! endif error = nf90_def_var(ncid, 'Time', NF90_FLOAT, dim_time, id_time) call netcdf_err(error, 'DEFINING TIME FIELD' ) @@ -2060,7 +2060,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_slmsk, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SLMSK COORD' ) - if(fract_grid)then +! if(fract_grid)then error = nf90_def_var(ncid, 'tsfcl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tsfcl) call netcdf_err(error, 'DEFINING TSFCL' ) error = nf90_put_att(ncid, id_tsfcl, "long_name", "tsfcl") @@ -2069,7 +2069,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING TSFCL UNITS' ) error = nf90_put_att(ncid, id_tsfcl, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TSFCL COORD' ) - endif +! endif error = nf90_def_var(ncid, 'tsea', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tsea) call netcdf_err(error, 'DEFINING TSEA' ) @@ -2089,7 +2089,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) ! error = nf90_put_att(ncid, id_sheleg, "coordinates", "geolon geolat") ! call netcdf_err(error, 'DEFINING SHELEG COORD' ) - if(fract_grid)then +! if(fract_grid)then error = nf90_def_var(ncid, 'weasdi', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_ice) call netcdf_err(error, 'DEFINING SHELEG AT ICE' ) error = nf90_put_att(ncid, id_sheleg_ice, "long_name", "sheleg_ice") @@ -2107,7 +2107,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING SHELEG AT ICE UNITS' ) error = nf90_put_att(ncid, id_sheleg_land, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SHELEG AT ICE COORD' ) - endif +! endif error = nf90_def_var(ncid, 'tg3', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3) call netcdf_err(error, 'DEFINING TG3' ) @@ -2366,7 +2366,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) ! error = nf90_put_att(ncid, id_snwdph, "coordinates", "geolon geolat") ! call netcdf_err(error, 'DEFINING SNWDPH COORD' ) - if(fract_grid)then +! if(fract_grid)then error = nf90_def_var(ncid, 'snodi', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph_ice) call netcdf_err(error, 'DEFINING SNWDPH AT ICE' ) error = nf90_put_att(ncid, id_snwdph_ice, "long_name", "snwdph_ice") @@ -2384,7 +2384,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING SNWDPH AT ICE UNITS' ) error = nf90_put_att(ncid, id_snwdph_land, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SNWDPH AT ICE COORD' ) - endif +! endif error = nf90_def_var(ncid, 'shdmin', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_shdmin) call netcdf_err(error, 'DEFINING SHDMIN' ) @@ -2460,7 +2460,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_slc, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SLC COORD' ) - if(fract_grid)then +! if(fract_grid)then error = nf90_def_var(ncid, 'tiice', NF90_DOUBLE, (/dim_x,dim_y,dim_ice,dim_time/), id_stc_ice) call netcdf_err(error, 'DEFINING STC_ICE' ) error = nf90_put_att(ncid, id_stc_ice, "long_name", "stc_ice") @@ -2469,7 +2469,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING STC_ICE UNITS' ) error = nf90_put_att(ncid, id_stc_ice, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING STC_ICE COORD' ) - endif +! endif if (convert_nst) then @@ -2645,10 +2645,10 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then error = nf90_put_var( ncid, id_lsoil, lsoil_data) call netcdf_err(error, 'WRITING ZAXIS RECORD' ) - if (fract_grid) then +! if (fract_grid) then error = nf90_put_var( ncid, id_ice, (/1,2/)) call netcdf_err(error, 'WRITING ZAXIS2 RECORD' ) - endif +! endif error = nf90_put_var( ncid, id_x, x_data) call netcdf_err(error, 'WRITING XAXIS RECORD' ) error = nf90_put_var( ncid, id_y, y_data) @@ -2694,7 +2694,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) ! call netcdf_err(error, 'WRITING SNOW LIQ EQUIV RECORD' ) endif - if(fract_grid) then +! if(fract_grid) then print*,"- CALL FieldGather FOR TARGET GRID SNOW LIQ EQUIV at ice FOR TILE: ", tile call ESMF_FieldGather(snow_liq_equiv_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) @@ -2707,7 +2707,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SNOW LIQ EQUIV at ice RECORD' ) endif - endif +! endif print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH FOR TILE: ", tile call ESMF_FieldGather(snow_depth_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) @@ -2723,7 +2723,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) ! call netcdf_err(error, 'WRITING SNWDPH RECORD' ) endif - if (fract_grid)then +! if (fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH at ice FOR TILE: ", tile call ESMF_FieldGather(snow_depth_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2735,7 +2735,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SNWDPH at ice RECORD' ) endif - endif +! endif print*,"- CALL FieldGather FOR TARGET GRID SLOPE TYPE FOR TILE: ", tile call ESMF_FieldGather(slope_type_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) @@ -2760,7 +2760,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) ! call netcdf_err(error, 'WRITING Z0 RECORD' ) ! endif - if(fract_grid)then +! if(fract_grid)then ! print*,"- CALL FieldGather FOR TARGET GRID Z0_land FOR TILE: ", tile ! call ESMF_FieldGather(z0_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) @@ -2796,7 +2796,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) endif - endif +! endif print*,"- CALL FieldGather FOR TARGET GRID MAX SNOW ALBEDO FOR TILE: ", tile call ESMF_FieldGather(mxsno_albedo_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) @@ -3089,16 +3089,16 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) - if(fract_grid)then +! if(fract_grid)then error = nf90_put_var( ncid, id_tsfcl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING TSFCL RECORD' ) - else - error = nf90_put_var( ncid, id_tsea, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING TSFC RECORD' ) - endif +! else +! error = nf90_put_var( ncid, id_tsea, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) +! call netcdf_err(error, 'WRITING TSFC RECORD' ) +! endif endif - if(fract_grid)then +! if(fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID sst FOR TILE: ", tile call ESMF_FieldGather(sst_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -3109,7 +3109,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_tsea, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING TSEA RECORD' ) endif - endif +! endif print*,"- CALL FieldGather FOR TARGET GRID LANDMASK FOR TILE: ", tile call ESMF_FieldGather(landmask_target_grid, idata_one_tile, rootPet=0, tile=tile, rc=error) @@ -3135,7 +3135,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) ! ice temperature - if(fract_grid)then +! if(fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID sea ice TEMPERATURE FOR TILE: ", tile call ESMF_FieldGather(ice_temp_target_grid, data_one_tile_3d, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -3146,7 +3146,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_stc_ice, dum3d(:,:,1:2), start=(/1,1,1,1/), count=(/i_target_out,j_target_out,2,1/)) call netcdf_err(error, 'WRITING sea ice TEMP RECORD' ) endif - endif +! endif ! soil temperature From 560eedbc6cbb66e0c553f89e2bbb857f382d5810 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 8 Aug 2023 17:12:08 +0000 Subject: [PATCH 065/107] Cleanup write_data.F90 by removing old fractional grid logic. Program will always output 'fractional' coldstart files. Fixes #123 --- sorc/chgres_cube.fd/write_data.F90 | 240 +++++++---------------------- 1 file changed, 53 insertions(+), 187 deletions(-) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 98d667130..d1c4b8181 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1811,8 +1811,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) i_target, j_target, lsoil_target use program_setup, only : convert_nst, halo=>halo_bndy, & - regional, lai_from_climo, & - fract_grid + regional, lai_from_climo use surface_target_data, only : canopy_mc_target_grid, & f10m_target_grid, & @@ -1835,7 +1834,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) t2m_target_grid, & tprcp_target_grid, & ustar_target_grid, & - z0_target_grid, & z0_ice_target_grid, & z0_water_target_grid, & lai_target_grid, & @@ -1884,20 +1882,17 @@ subroutine write_fv3_sfc_data_netcdf(localpet) integer :: id_x, id_y, id_lsoil, id_ice integer :: id_slmsk, id_time integer :: id_lat, id_lon - integer :: id_tsfcl, id_tsea, id_sheleg, id_sheleg_ice, id_sheleg_land, id_tg3 -!integer :: id_tsfcl, id_tsea, id_sheleg, id_tg3 - integer :: id_zorl, id_zorl_land, id_zorl_ice, id_alvsf, id_alvwf - integer :: id_zorl_water + integer :: id_tsfcl, id_tsea, id_sheleg_ice, id_sheleg_land + integer :: id_zorl_water, id_zorl_ice, id_alvsf, id_alvwf integer :: id_alnsf, id_alnwf, id_vfrac - integer :: id_canopy, id_f10m, id_t2m + integer :: id_canopy, id_f10m, id_t2m, id_tg3 integer :: id_q2m, id_vtype, id_stype integer :: id_facsf, id_facwf, id_uustar integer :: id_ffmm, id_ffhh, id_hice integer :: id_fice, id_tisfc, id_tprcp - integer :: id_srflag, id_snwdph, id_snwdph_ice, id_snwdph_land, id_shdmin -!integer :: id_srflag, id_snwdph, id_shdmin + integer :: id_srflag, id_snwdph_ice, id_snwdph_land, id_shdmin integer :: id_shdmax, id_slope, id_snoalb - integer :: id_lai, id_stc_ice + integer :: id_lai, id_ice_temp integer :: id_stc, id_smc, id_slc integer :: id_tref, id_z_c, id_c_0 integer :: id_c_d, id_w_0, id_w_d @@ -1982,10 +1977,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING YAXIS DIMENSION' ) error = nf90_def_dim(ncid, 'zaxis_1', lsoil_target, dim_lsoil) call netcdf_err(error, 'DEFINING ZAXIS DIMENSION' ) -! if (fract_grid) then - error = nf90_def_dim(ncid, 'zaxis_2', 2, dim_ice) - call netcdf_err(error, 'DEFINING ZAXIS2 DIMENSION' ) -! endif + error = nf90_def_dim(ncid, 'zaxis_2', 2, dim_ice) + call netcdf_err(error, 'DEFINING ZAXIS2 DIMENSION' ) error = nf90_def_dim(ncid, 'Time', 1, dim_time) call netcdf_err(error, 'DEFINING TIME DIMENSION' ) @@ -2017,16 +2010,14 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_lsoil, "cartesian_axis", "Z") call netcdf_err(error, 'WRITING ZAXIS_1 FIELD' ) -! if (fract_grid) then - error = nf90_def_var(ncid, 'zaxis_2', NF90_FLOAT, (/dim_ice/), id_ice) - call netcdf_err(error, 'DEFINING ZAXIS_2 FIELD' ) - error = nf90_put_att(ncid, id_ice, "long_name", "zaxis_2") - call netcdf_err(error, 'DEFINING ZAXIS_2 LONG NAME' ) - error = nf90_put_att(ncid, id_ice, "units", "none") - call netcdf_err(error, 'DEFINING ZAXIS_2 UNITS' ) - error = nf90_put_att(ncid, id_ice, "cartesian_axis", "Z") - call netcdf_err(error, 'WRITING ZAXIS_2 FIELD' ) -! endif + error = nf90_def_var(ncid, 'zaxis_2', NF90_FLOAT, (/dim_ice/), id_ice) + call netcdf_err(error, 'DEFINING ZAXIS_2 FIELD' ) + error = nf90_put_att(ncid, id_ice, "long_name", "zaxis_2") + call netcdf_err(error, 'DEFINING ZAXIS_2 LONG NAME' ) + error = nf90_put_att(ncid, id_ice, "units", "none") + call netcdf_err(error, 'DEFINING ZAXIS_2 UNITS' ) + error = nf90_put_att(ncid, id_ice, "cartesian_axis", "Z") + call netcdf_err(error, 'WRITING ZAXIS_2 FIELD' ) error = nf90_def_var(ncid, 'Time', NF90_FLOAT, dim_time, id_time) call netcdf_err(error, 'DEFINING TIME FIELD' ) @@ -2060,7 +2051,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_slmsk, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SLMSK COORD' ) -! if(fract_grid)then error = nf90_def_var(ncid, 'tsfcl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tsfcl) call netcdf_err(error, 'DEFINING TSFCL' ) error = nf90_put_att(ncid, id_tsfcl, "long_name", "tsfcl") @@ -2069,7 +2059,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING TSFCL UNITS' ) error = nf90_put_att(ncid, id_tsfcl, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TSFCL COORD' ) -! endif error = nf90_def_var(ncid, 'tsea', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tsea) call netcdf_err(error, 'DEFINING TSEA' ) @@ -2080,34 +2069,23 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_tsea, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TSEA COORD' ) -! error = nf90_def_var(ncid, 'sheleg', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg) -! call netcdf_err(error, 'DEFINING SHELEG' ) -! error = nf90_put_att(ncid, id_sheleg, "long_name", "sheleg") -! call netcdf_err(error, 'DEFINING SHELEG LONG NAME' ) -! error = nf90_put_att(ncid, id_sheleg, "units", "none") -! call netcdf_err(error, 'DEFINING SHELEG UNITS' ) -! error = nf90_put_att(ncid, id_sheleg, "coordinates", "geolon geolat") -! call netcdf_err(error, 'DEFINING SHELEG COORD' ) - -! if(fract_grid)then error = nf90_def_var(ncid, 'weasdi', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_ice) - call netcdf_err(error, 'DEFINING SHELEG AT ICE' ) + call netcdf_err(error, 'DEFINING WEASD/SHELEG AT ICE' ) error = nf90_put_att(ncid, id_sheleg_ice, "long_name", "sheleg_ice") - call netcdf_err(error, 'DEFINING SHELEG ICE LONG NAME' ) + call netcdf_err(error, 'DEFINING WEASD/SHELEG ICE LONG NAME' ) error = nf90_put_att(ncid, id_sheleg_ice, "units", "none") - call netcdf_err(error, 'DEFINING SHELEG AT ICE UNITS' ) + call netcdf_err(error, 'DEFINING WEASD/SHELEG AT ICE UNITS' ) error = nf90_put_att(ncid, id_sheleg_ice, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING SHELEG AT ICE COORD' ) + call netcdf_err(error, 'DEFINING WEASD/SHELEG AT ICE COORD' ) error = nf90_def_var(ncid, 'weasdl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_land) - call netcdf_err(error, 'DEFINING SHELEG AT ICE' ) + call netcdf_err(error, 'DEFINING WEASD/SHELEG AT LAND' ) error = nf90_put_att(ncid, id_sheleg_land, "long_name", "sheleg_land") - call netcdf_err(error, 'DEFINING SHELEG ICE LONG NAME' ) + call netcdf_err(error, 'DEFINING WEASD/SHELEG LAND LONG NAME' ) error = nf90_put_att(ncid, id_sheleg_land, "units", "none") - call netcdf_err(error, 'DEFINING SHELEG AT ICE UNITS' ) + call netcdf_err(error, 'DEFINING WEASD/SHELEG AT LAND UNITS' ) error = nf90_put_att(ncid, id_sheleg_land, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING SHELEG AT ICE COORD' ) -! endif + call netcdf_err(error, 'DEFINING SHELEG AT LAND COORD' ) error = nf90_def_var(ncid, 'tg3', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3) call netcdf_err(error, 'DEFINING TG3' ) @@ -2118,37 +2096,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_tg3, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TG3 COORD' ) -! if(fract_grid)then -! error = nf90_def_var(ncid, 'tg3_ice', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3_ice) -! call netcdf_err(error, 'DEFINING TG3_ICE' ) -! error = nf90_put_att(ncid, id_tg3_ice, "long_name", "tg3_ice") -! call netcdf_err(error, 'DEFINING TG3_ICE LONG NAME' ) -! error = nf90_put_att(ncid, id_tg3_ice, "units", "none") -! call netcdf_err(error, 'DEFINING TG3_ICE UNITS' ) -! error = nf90_put_att(ncid, id_tg3_ice, "coordinates", "geolon geolat") -! call netcdf_err(error, 'DEFINING TG3_ICE COORD' ) -! endif - -! if(.not.fract_grid)then -! error = nf90_def_var(ncid, 'zorl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl) -! call netcdf_err(error, 'DEFINING ZORL' ) -! error = nf90_put_att(ncid, id_zorl, "long_name", "zorl") -! call netcdf_err(error, 'DEFINING ZORL LONG NAME' ) -! error = nf90_put_att(ncid, id_zorl, "units", "none") -! call netcdf_err(error, 'DEFINING ZORL UNITS' ) -! error = nf90_put_att(ncid, id_zorl, "coordinates", "geolon geolat") -! call netcdf_err(error, 'DEFINING ZORL COORD' ) - -! else -! error = nf90_def_var(ncid, 'zorll', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_land) -! call netcdf_err(error, 'DEFINING ZORLL' ) -! error = nf90_put_att(ncid, id_zorl_land, "long_name", "zorll") -! call netcdf_err(error, 'DEFINING ZORLL LONG NAME' ) -! error = nf90_put_att(ncid, id_zorl_land, "units", "none") -! call netcdf_err(error, 'DEFINING ZORLL UNITS' ) -! error = nf90_put_att(ncid, id_zorl_land, "coordinates", "geolon geolat") -! call netcdf_err(error, 'DEFINING ZORLL COORD' ) - error = nf90_def_var(ncid, 'zorli', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_ice) call netcdf_err(error, 'DEFINING ZORLI' ) error = nf90_put_att(ncid, id_zorl_ice, "long_name", "zorli") @@ -2166,7 +2113,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ZORLW UNITS' ) error = nf90_put_att(ncid, id_zorl_water, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ZORLW COORD' ) -! endif error = nf90_def_var(ncid, 'alvsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvsf) call netcdf_err(error, 'DEFINING ALVSF' ) @@ -2357,16 +2303,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_srflag, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SRFLAG COORD' ) -! error = nf90_def_var(ncid, 'snwdph', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph) -! call netcdf_err(error, 'DEFINING SNWDPH' ) -! error = nf90_put_att(ncid, id_snwdph, "long_name", "snwdph") -! call netcdf_err(error, 'DEFINING SNWDPH LONG NAME' ) -! error = nf90_put_att(ncid, id_snwdph, "units", "none") -! call netcdf_err(error, 'DEFINING SNWDPH UNITS' ) -! error = nf90_put_att(ncid, id_snwdph, "coordinates", "geolon geolat") -! call netcdf_err(error, 'DEFINING SNWDPH COORD' ) - -! if(fract_grid)then error = nf90_def_var(ncid, 'snodi', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph_ice) call netcdf_err(error, 'DEFINING SNWDPH AT ICE' ) error = nf90_put_att(ncid, id_snwdph_ice, "long_name", "snwdph_ice") @@ -2384,7 +2320,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING SNWDPH AT ICE UNITS' ) error = nf90_put_att(ncid, id_snwdph_land, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SNWDPH AT ICE COORD' ) -! endif error = nf90_def_var(ncid, 'shdmin', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_shdmin) call netcdf_err(error, 'DEFINING SHDMIN' ) @@ -2460,16 +2395,14 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_slc, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SLC COORD' ) -! if(fract_grid)then - error = nf90_def_var(ncid, 'tiice', NF90_DOUBLE, (/dim_x,dim_y,dim_ice,dim_time/), id_stc_ice) - call netcdf_err(error, 'DEFINING STC_ICE' ) - error = nf90_put_att(ncid, id_stc_ice, "long_name", "stc_ice") - call netcdf_err(error, 'DEFINING STC_ICE LONG NAME' ) - error = nf90_put_att(ncid, id_stc_ice, "units", "none") - call netcdf_err(error, 'DEFINING STC_ICE UNITS' ) - error = nf90_put_att(ncid, id_stc_ice, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING STC_ICE COORD' ) -! endif + error = nf90_def_var(ncid, 'tiice', NF90_DOUBLE, (/dim_x,dim_y,dim_ice,dim_time/), id_ice_temp) + call netcdf_err(error, 'DEFINING TIICE' ) + error = nf90_put_att(ncid, id_ice_temp, "long_name", "tiice") + call netcdf_err(error, 'DEFINING TIICE LONG NAME' ) + error = nf90_put_att(ncid, id_ice_temp, "units", "none") + call netcdf_err(error, 'DEFINING TIICE UNITS' ) + error = nf90_put_att(ncid, id_ice_temp, "coordinates", "geolon geolat") + call netcdf_err(error, 'DEFINING TIICE COORD' ) if (convert_nst) then @@ -2645,10 +2578,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then error = nf90_put_var( ncid, id_lsoil, lsoil_data) call netcdf_err(error, 'WRITING ZAXIS RECORD' ) -! if (fract_grid) then - error = nf90_put_var( ncid, id_ice, (/1,2/)) - call netcdf_err(error, 'WRITING ZAXIS2 RECORD' ) -! endif + error = nf90_put_var( ncid, id_ice, (/1,2/)) + call netcdf_err(error, 'WRITING ZAXIS2 RECORD' ) error = nf90_put_var( ncid, id_x, x_data) call netcdf_err(error, 'WRITING XAXIS RECORD' ) error = nf90_put_var( ncid, id_y, y_data) @@ -2680,7 +2611,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING LONGITUDE RECORD' ) endif - print*,"- CALL FieldGather FOR TARGET GRID SNOW LIQ EQUIV FOR TILE: ", tile + print*,"- CALL FieldGather FOR TARGET GRID SNOW LIQ EQUIV AT LAND FOR TILE: ", tile call ESMF_FieldGather(snow_liq_equiv_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", error) @@ -2688,15 +2619,10 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) error = nf90_put_var( ncid, id_sheleg_land, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING SNOW LIQ EQUIV RECORD' ) -! dum2d(:,:) = 1.e20 -! error = nf90_put_var( ncid, id_sheleg, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) -! call netcdf_err(error, 'WRITING SNOW LIQ EQUIV RECORD' ) + call netcdf_err(error, 'WRITING SNOW LIQ EQUIV AT LAND RECORD' ) endif -! if(fract_grid) then - - print*,"- CALL FieldGather FOR TARGET GRID SNOW LIQ EQUIV at ice FOR TILE: ", tile + print*,"- CALL FieldGather FOR TARGET GRID SNOW LIQ EQUIV AT ICE FOR TILE: ", tile call ESMF_FieldGather(snow_liq_equiv_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", error) @@ -2704,12 +2630,10 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) error = nf90_put_var( ncid, id_sheleg_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING SNOW LIQ EQUIV at ice RECORD' ) + call netcdf_err(error, 'WRITING SNOW LIQ EQUIV AT ICE RECORD' ) endif -! endif - - print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH FOR TILE: ", tile + print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH AT LAND FOR TILE: ", tile call ESMF_FieldGather(snow_depth_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", error) @@ -2717,14 +2641,10 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) error = nf90_put_var( ncid, id_snwdph_land, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING SNWDPH RECORD' ) -! dum2d(:,:) = 1.e20 -! error = nf90_put_var( ncid, id_snwdph, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) -! call netcdf_err(error, 'WRITING SNWDPH RECORD' ) + call netcdf_err(error, 'WRITING SNWDPH AT LAND RECORD' ) endif -! if (fract_grid)then - print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH at ice FOR TILE: ", tile + print*,"- CALL FieldGather FOR TARGET GRID SNOW DEPTH AT ICE FOR TILE: ", tile call ESMF_FieldGather(snow_depth_at_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", error) @@ -2732,11 +2652,9 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) error = nf90_put_var( ncid, id_snwdph_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING SNWDPH at ice RECORD' ) + call netcdf_err(error, 'WRITING SNWDPH AT ICE RECORD' ) endif -! endif - print*,"- CALL FieldGather FOR TARGET GRID SLOPE TYPE FOR TILE: ", tile call ESMF_FieldGather(slope_type_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2748,31 +2666,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SLOPE RECORD' ) endif -! print*,"- CALL FieldGather FOR TARGET GRID Z0 FOR TILE: ", tile -! call ESMF_FieldGather(z0_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) -! if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldGather", error) - -! if (localpet == 0) then -! dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) -! dum2d(:,:) = 1.e20 -! error = nf90_put_var( ncid, id_zorl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) -! call netcdf_err(error, 'WRITING Z0 RECORD' ) -! endif - -! if(fract_grid)then - -! print*,"- CALL FieldGather FOR TARGET GRID Z0_land FOR TILE: ", tile -! call ESMF_FieldGather(z0_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) -! if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldGather", error) - -! if (localpet == 0) then -! dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) -! error = nf90_put_var( ncid, id_zorl_land, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) -! call netcdf_err(error, 'WRITING Z0_LAND RECORD' ) -! endif - print*,"- CALL FieldGather FOR TARGET GRID Z0_ICE FOR TILE: ", tile call ESMF_FieldGather(z0_ice_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2795,9 +2688,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING Z0_WATER RECORD' ) endif - -! endif - print*,"- CALL FieldGather FOR TARGET GRID MAX SNOW ALBEDO FOR TILE: ", tile call ESMF_FieldGather(mxsno_albedo_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2866,21 +2756,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING SUBSTRATE TEMPERATURE RECORD' ) endif -! if(fract_grid) then - -! print*,"- CALL FieldGather FOR TARGET GRID SEAICE SUBSTRATE TEMPERATURE FOR TILE: ", tile -! call ESMF_FieldGather(seaice_substrate_temp_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) -! if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldGather", error) - -! if (localpet == 0) then -! dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) -! error = nf90_put_var( ncid, id_tg3_ice, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) -! call netcdf_err(error, 'WRITING SEAICE SUBSTRATE TEMPERATURE RECORD' ) -! endif - -! endif - print*,"- CALL FieldGather FOR TARGET GRID FACSF FOR TILE: ", tile call ESMF_FieldGather(facsf_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -3089,16 +2964,10 @@ subroutine write_fv3_sfc_data_netcdf(localpet) if (localpet == 0) then dum2d(:,:) = data_one_tile(istart:iend, jstart:jend) -! if(fract_grid)then - error = nf90_put_var( ncid, id_tsfcl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) - call netcdf_err(error, 'WRITING TSFCL RECORD' ) -! else -! error = nf90_put_var( ncid, id_tsea, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) -! call netcdf_err(error, 'WRITING TSFC RECORD' ) -! endif + error = nf90_put_var( ncid, id_tsfcl, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) + call netcdf_err(error, 'WRITING TSFCL RECORD' ) endif -! if(fract_grid)then print*,"- CALL FieldGather FOR TARGET GRID sst FOR TILE: ", tile call ESMF_FieldGather(sst_target_grid, data_one_tile, rootPet=0, tile=tile, rc=error) if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -3109,7 +2978,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_var( ncid, id_tsea, dum2d, start=(/1,1,1/), count=(/i_target_out,j_target_out,1/)) call netcdf_err(error, 'WRITING TSEA RECORD' ) endif -! endif print*,"- CALL FieldGather FOR TARGET GRID LANDMASK FOR TILE: ", tile call ESMF_FieldGather(landmask_target_grid, idata_one_tile, rootPet=0, tile=tile, rc=error) @@ -3133,20 +3001,18 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'WRITING CANOPY MC RECORD' ) endif -! ice temperature +! ice column temperature -! if(fract_grid)then - print*,"- CALL FieldGather FOR TARGET GRID sea ice TEMPERATURE FOR TILE: ", tile - call ESMF_FieldGather(ice_temp_target_grid, data_one_tile_3d, rootPet=0, tile=tile, rc=error) - if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + print*,"- CALL FieldGather FOR TARGET GRID SEA ICE COLUMN TEMPERATURE FOR TILE: ", tile + call ESMF_FieldGather(ice_temp_target_grid, data_one_tile_3d, rootPet=0, tile=tile, rc=error) + if(ESMF_logFoundError(rcToCheck=error,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", error) - if (localpet == 0) then - dum3d(:,:,:) = data_one_tile_3d(istart:iend, jstart:jend,:) - error = nf90_put_var( ncid, id_stc_ice, dum3d(:,:,1:2), start=(/1,1,1,1/), count=(/i_target_out,j_target_out,2,1/)) - call netcdf_err(error, 'WRITING sea ice TEMP RECORD' ) - endif -! endif + if (localpet == 0) then + dum3d(:,:,:) = data_one_tile_3d(istart:iend, jstart:jend,:) + error = nf90_put_var( ncid, id_ice_temp, dum3d(:,:,1:2), start=(/1,1,1,1/), count=(/i_target_out,j_target_out,2,1/)) + call netcdf_err(error, 'WRITING SEA ICE COLUMN TEMP RECORD' ) + endif ! soil temperature From 581024556d1ff1582965608fff624f0365d3f829 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 8 Aug 2023 18:33:01 +0000 Subject: [PATCH 066/107] Remove sea ice substrate temperature, which is not used by the model. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 77 +++------------------ sorc/chgres_cube.fd/surface_target_data.F90 | 3 - 2 files changed, 10 insertions(+), 70 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 66e380a20..5ea164803 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2412,7 +2412,6 @@ subroutine qc_check real(esmf_kind_r8), pointer :: fice_ptr(:,:) real(esmf_kind_r8), pointer :: hice_ptr(:,:) real(esmf_kind_r8), pointer :: tg3_ptr(:,:) -!real(esmf_kind_r8), pointer :: tg3_ice_ptr(:,:) real(esmf_kind_r8), pointer :: snod_ptr(:,:) real(esmf_kind_r8), pointer :: snol_ptr(:,:) @@ -2703,56 +2702,20 @@ subroutine qc_check endif - print*,"- SET TARGET GRID SUBSTRATE TEMP AT ICE." + print*,"- SET MISSING FLAG AT TARGET GRID SUBSTRATE TEMP." -!if (fract_grid) then - -! call ESMF_FieldGet(seaice_substrate_temp_target_grid, & -! farrayPtr=tg3_ice_ptr, rc=rc) -! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldGet", rc) - -! do j = clb(2), cub(2) -! do i = clb(1), cub(1) -! if (fice_ptr(i,j) > 0.0) then ! sea ice -! tg3_ice_ptr(i,j) = frz_ice -! else -! tg3_ice_ptr(i,j) = -1.e20 -! endif -! enddo -! enddo - - call ESMF_FieldGet(substrate_temp_target_grid, & + call ESMF_FieldGet(substrate_temp_target_grid, & farrayPtr=tg3_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0.0) then ! sea ice - tg3_ptr(i,j) = -1.e20 - endif - enddo - enddo - -!else - -!call ESMF_FieldGet(substrate_temp_target_grid, & -! farrayPtr=tg3_ptr, rc=rc) -!if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldGet", rc) - -!do j = clb(2), cub(2) -!do i = clb(1), cub(1) -! if (fice_ptr(i,j) > 0.0) then ! sea ice -! tg3_ptr(i,j) = frz_ice -! elseif (landmask_ptr(i,j) == 0) then ! open water flag value. -! tg3_ptr(i,j) = skint_ptr(i,j) -! endif -!enddo -!enddo - -!endif + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0.0) then ! non-land + tg3_ptr(i,j) = -1.e20 + endif + enddo + enddo !if (fract_grid) then @@ -3278,26 +3241,6 @@ subroutine create_surface_esmf_fields target_ptr = init_val -!if (fract_grid) then - -! print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE SUBSTRATE TEMP." -! seaice_substrate_temp_target_grid = ESMF_FieldCreate(target_grid, & -! typekind=ESMF_TYPEKIND_R8, & -! name="seaice_substrate_temp_target_grid", & -! staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) -! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldCreate", rc) - -! print*,"- INITIALIZE TARGET sea ice substrate temp." -! call ESMF_FieldGet(seaice_substrate_temp_target_grid, & -! farrayPtr=target_ptr, rc=rc) -! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldGet", rc) - -! target_ptr = init_val - -!endif - print*,"- CALL FieldCreate FOR TARGET GRID SRFLAG." srflag_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & diff --git a/sorc/chgres_cube.fd/surface_target_data.F90 b/sorc/chgres_cube.fd/surface_target_data.F90 index 18b3a111e..12bbbc802 100644 --- a/sorc/chgres_cube.fd/surface_target_data.F90 +++ b/sorc/chgres_cube.fd/surface_target_data.F90 @@ -33,8 +33,6 @@ module surface_target_data !< Sea ice fraction. type(esmf_field), public :: seaice_skin_temp_target_grid !< Sea ice skin temperature. -!type(esmf_field), public :: seaice_substrate_temp_target_grid - !< Sea ice substrate temperature. type(esmf_field), public :: skin_temp_target_grid !< Skin temperature/sst. type(esmf_field), public :: sst_target_grid @@ -144,7 +142,6 @@ subroutine cleanup_target_sfc_data call ESMF_FieldDestroy(seaice_fract_target_grid, rc=rc) call ESMF_FieldDestroy(seaice_depth_target_grid, rc=rc) call ESMF_FieldDestroy(seaice_skin_temp_target_grid, rc=rc) -!if (ESMF_FieldIsCreated(seaice_substrate_temp_target_grid)) call ESMF_FieldDestroy(seaice_substrate_temp_target_grid, rc=rc) call ESMF_FieldDestroy(srflag_target_grid, rc=rc) call ESMF_FieldDestroy(skin_temp_target_grid, rc=rc) if (ESMF_FieldIsCreated(sst_target_grid)) call ESMF_FieldDestroy(sst_target_grid, rc=rc) From c4924eeb75adba924f69eade952ec8ac7b454a36 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 9 Aug 2023 12:39:08 +0000 Subject: [PATCH 067/107] Remove references to z0 at land, which is set in the model. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 54 +-------------------- sorc/chgres_cube.fd/surface_target_data.F90 | 7 +-- 2 files changed, 3 insertions(+), 58 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 5ea164803..e226795b2 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -29,7 +29,7 @@ module surface srflag_target_grid, soil_temp_target_grid, & seaice_depth_target_grid, snow_liq_equiv_target_grid, & seaice_skin_temp_target_grid, skin_temp_target_grid, & - snow_depth_target_grid, z0_target_grid, & + snow_depth_target_grid, & c_d_target_grid, c_0_target_grid, & d_conv_target_grid, dt_cool_target_grid, & ifd_target_grid, qrain_target_grid, & @@ -973,11 +973,7 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleCreate", rc) -!if(fract_grid)then call ESMF_FieldBundleAdd(bundle_water_target, (/sst_target_grid, z0_water_target_grid/), rc=rc) -!else -!call ESMF_FieldBundleAdd(bundle_water_target, (/skin_temp_target_grid, z0_target_grid/), rc=rc) -!endif if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) @@ -2243,7 +2239,6 @@ subroutine roughness use model_grid, only : landmask_target_grid, & seamask_target_grid - use static_data, only : veg_type_target_grid use program_setup, only : fract_grid implicit none @@ -2252,17 +2247,9 @@ subroutine roughness integer(esmf_kind_i8), pointer :: landmask_ptr(:,:) integer(esmf_kind_i8), pointer :: seamask_ptr(:,:) - real :: z0_igbp(20) - real(esmf_kind_r8), pointer :: data_ptr(:,:) real(esmf_kind_r8), pointer :: data_ptr2(:,:) real(esmf_kind_r8), pointer :: data_ptr3(:,:) real(esmf_kind_r8), pointer :: fice_ptr(:,:) - real(esmf_kind_r8), pointer :: veg_type_ptr(:,:) - - data z0_igbp /1.089, 2.653, 0.854, 0.826, 0.800, 0.050, & - 0.030, 0.856, 0.856, 0.150, 0.040, 0.130, & - 1.000, 0.250, 0.011, 0.011, 0.001, 0.076, & - 0.050, 0.030/ print*,"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK." call ESMF_FieldGet(landmask_target_grid, & @@ -2278,18 +2265,6 @@ subroutine roughness if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - print*,"- CALL FieldGet FOR TARGET GRID VEGETATION TYPE." - call ESMF_FieldGet(veg_type_target_grid, & - farrayPtr=veg_type_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - - print*,"- CALL FieldGet FOR TARGET GRID Z0." - call ESMF_FieldGet(z0_target_grid, & - farrayPtr=data_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - print*,"- CALL FieldGet FOR TARGET GRID Z0 WATER." call ESMF_FieldGet(z0_water_target_grid, & farrayPtr=data_ptr3, rc=rc) @@ -2321,15 +2296,6 @@ subroutine roughness if(fract_grid)then - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 1) then - data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0 - else - data_ptr(i,j) = 1.e20 - endif - enddo - enddo ! print*,"- CALL FieldGet FOR TARGET GRID Z0 WATER." ! call ESMF_FieldGet(z0_water_target_grid, & @@ -2359,8 +2325,6 @@ subroutine roughness do i = clb(1), cub(1) if (fice_ptr(i,j) > 0.0 .or. seamask_ptr(i,j) == 0) then data_ptr3(i,j) = 1.e20 -! elseif (landmask_ptr(i,j) == 1) then -! data_ptr(i,j) = z0_igbp(nint(veg_type_ptr(i,j))) * 100.0 endif enddo enddo @@ -3305,22 +3269,6 @@ subroutine create_surface_esmf_fields target_ptr = init_val - print*,"- CALL FieldCreate FOR TARGET GRID Z0." - z0_target_grid = ESMF_FieldCreate(target_grid, & - typekind=ESMF_TYPEKIND_R8, & - name="z0_target_grid", & - staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldCreate", rc) - - print*,"- INITIALIZE TARGET grid z0." - call ESMF_FieldGet(z0_target_grid, & - farrayPtr=target_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGet", rc) - - target_ptr = init_val - !if (fract_grid)then print*,"- CALL FieldCreate FOR TARGET GRID Z0_ICE." z0_ice_target_grid = ESMF_FieldCreate(target_grid, & diff --git a/sorc/chgres_cube.fd/surface_target_data.F90 b/sorc/chgres_cube.fd/surface_target_data.F90 index 12bbbc802..1520a5b73 100644 --- a/sorc/chgres_cube.fd/surface_target_data.F90 +++ b/sorc/chgres_cube.fd/surface_target_data.F90 @@ -60,8 +60,6 @@ module surface_target_data !< Precipitation. type(esmf_field), public :: ustar_target_grid !< Friction velocity. - type(esmf_field), public :: z0_target_grid - !< Roughness length. type(esmf_field), public :: z0_ice_target_grid !< roughness length at sea ice type(esmf_field), public :: z0_water_target_grid @@ -147,9 +145,8 @@ subroutine cleanup_target_sfc_data if (ESMF_FieldIsCreated(sst_target_grid)) call ESMF_FieldDestroy(sst_target_grid, rc=rc) call ESMF_FieldDestroy(canopy_mc_target_grid, rc=rc) call ESMF_FieldDestroy(lai_target_grid,rc=rc) - call ESMF_FieldDestroy(z0_target_grid, rc=rc) - if (ESMF_FieldIsCreated(z0_ice_target_grid)) call ESMF_FieldDestroy(z0_ice_target_grid, rc=rc) - if (ESMF_FieldIsCreated(z0_water_target_grid)) call ESMF_FieldDestroy(z0_water_target_grid, rc=rc) + call ESMF_FieldDestroy(z0_ice_target_grid, rc=rc) + call ESMF_FieldDestroy(z0_water_target_grid, rc=rc) call ESMF_FieldDestroy(soil_temp_target_grid, rc=rc) call ESMF_FieldDestroy(soilm_tot_target_grid, rc=rc) call ESMF_FieldDestroy(soilm_liq_target_grid, rc=rc) From defd311834b4e3863ad85b1c27b40402a8d948da Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 9 Aug 2023 12:59:26 +0000 Subject: [PATCH 068/107] Remove fractional logic from model_grid.F90. Fixes #123. --- sorc/chgres_cube.fd/model_grid.F90 | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sorc/chgres_cube.fd/model_grid.F90 b/sorc/chgres_cube.fd/model_grid.F90 index 30ffabae4..7277b1af9 100644 --- a/sorc/chgres_cube.fd/model_grid.F90 +++ b/sorc/chgres_cube.fd/model_grid.F90 @@ -887,7 +887,7 @@ subroutine define_target_grid(localpet, npets) use program_setup, only : mosaic_file_target_grid, & orog_dir_target_grid, & orog_files_target_grid, & - nsoill_out, fract_grid + nsoill_out implicit none @@ -1106,15 +1106,10 @@ subroutine define_target_grid(localpet, npets) call get_model_mask_terrain(trim(the_file), i_target, j_target, landmask_one_tile, & terrain_one_tile, land_frac_one_tile) - if (fract_grid) then - seamask_one_tile = 0 ! all land - where(floor(land_frac_one_tile) == 0) seamask_one_tile = 1 ! at least some non-land. - landmask_one_tile = 0 ! all non-land - where(ceiling(land_frac_one_tile) == 1) landmask_one_tile = 1 ! at least some land - else - seamask_one_tile = 0 ! all land - where(landmask_one_tile == 0) seamask_one_tile=1 ! not land - endif + seamask_one_tile = 0 ! all land + where(floor(land_frac_one_tile) == 0) seamask_one_tile = 1 ! at least some non-land. + landmask_one_tile = 0 ! all non-land + where(ceiling(land_frac_one_tile) == 1) landmask_one_tile = 1 ! at least some land call get_model_latlons(mosaic_file_target_grid, orog_dir_target_grid, num_tiles_target_grid, tile, & i_target, j_target, ip1_target, jp1_target, latitude_one_tile, & From 3dd2a751aea3f15f07628ebed4f50d0b41594eef Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 9 Aug 2023 14:46:06 +0000 Subject: [PATCH 069/107] Some clean up. Fixes #123. --- sorc/chgres_cube.fd/model_grid.F90 | 9 +++-- sorc/chgres_cube.fd/surface.F90 | 58 ++++++++++-------------------- 2 files changed, 22 insertions(+), 45 deletions(-) diff --git a/sorc/chgres_cube.fd/model_grid.F90 b/sorc/chgres_cube.fd/model_grid.F90 index 7277b1af9..d18529316 100644 --- a/sorc/chgres_cube.fd/model_grid.F90 +++ b/sorc/chgres_cube.fd/model_grid.F90 @@ -70,10 +70,9 @@ module model_grid type(esmf_field), public :: longitude_w_input_grid !< longitude of 'west' edge of grid !! box, input grid - type(esmf_field), public :: landmask_target_grid - !< land mask target grid - '1' land; - !! '0' non-land + !< land mask target grid - '1' some or all land; + !! '0' all non-land type(esmf_field), public :: land_frac_target_grid !< land fraction, target grid type(esmf_field), public :: latitude_target_grid @@ -93,8 +92,8 @@ module model_grid !< longitude of 'west' edge of grid !! box, target grid type(esmf_field), public :: seamask_target_grid - !< sea mask target grid - '1' non-land; - !! '0' land + !< sea mask target grid - '1' some or all non-land; + !! '0' all land type(esmf_field), public :: terrain_target_grid !< terrain height target grid diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index e226795b2..cdb1eaec4 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -529,7 +529,7 @@ subroutine interp(localpet) where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1 mask_target_ptr = 0 - where (landmask_target_ptr == 1) mask_target_ptr = 1 + where (landmask_target_ptr == 1) mask_target_ptr = 1 ! some or all land. print*,"- CALL FieldCreate FOR TERRAIN FROM INPUT GRID LAND." terrain_from_input_grid_land = ESMF_FieldCreate(target_grid, & @@ -659,7 +659,7 @@ subroutine interp(localpet) call error_handler("IN FieldRegridRelease", rc) !----------------------------------------------------------------------- -! Next, determine the sea ice fraction on target grid. +! Next, determine the sea ice fraction on the fractional target grid. ! For fractional grids, the ice fraction is not scaled for the ! fraction of non-land. So if a point is 50% land and non-land, ! an ice frac of 100% means the entire non-land portion is ice covered. @@ -668,9 +668,10 @@ subroutine interp(localpet) mask_input_ptr = 1 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 0 -! For non-fractional grids, 'seamask_target_ptr' is '0' for land points -! and '1' for non-land points. For fractional grids, 'seamask_target_ptr' -! will be '0' if all land and '1' is at least some non-land. +!----------------------------------------------------------------------- +! Map to grid points that are partial or all non-land. That is +! indicated where seamask_target is '1'. +!----------------------------------------------------------------------- mask_target_ptr = int(seamask_target_ptr,kind=esmf_kind_i4) @@ -745,14 +746,12 @@ subroutine interp(localpet) latitude=latitude_one_tile) endif -! When running with fractional grids, to reduce the number of points with small amounts of open water, -! set any point with ice between 95-100% to 100%. +!------------------------------------------------------------------------------ +! To reduce the potenitally large number of target grid points with a very +! small amount of open water, set any point with ice between 95-100% to 100%. +!------------------------------------------------------------------------------ - if (fract_grid) then - ice_lim = 0.95_esmf_kind_r8 - else - ice_lim = 1.0_esmf_kind_r8 - endif + ice_lim = 0.95_esmf_kind_r8 if (localpet == 0) then do j = 1, j_target @@ -798,7 +797,6 @@ subroutine interp(localpet) isrctermprocessing = 1 print*,"- CALL FieldRegridStore for 3d seaice fields." - if(fract_grid)then call ESMF_FieldRegridStore(soil_temp_input_grid, & ice_temp_target_grid, & srcmaskvalues=(/0/), & @@ -810,19 +808,7 @@ subroutine interp(localpet) routehandle=regrid_seaice, & regridmethod=method, & unmappedDstList=unmapped_ptr, rc=rc) - else - call ESMF_FieldRegridStore(soil_temp_input_grid, & - soil_temp_target_grid, & - srcmaskvalues=(/0/), & - dstmaskvalues=(/0/), & - polemethod=ESMF_POLEMETHOD_NONE, & - srctermprocessing=isrctermprocessing, & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & - normtype=ESMF_NORMTYPE_FRACAREA, & - routehandle=regrid_seaice, & - regridmethod=method, & - unmappedDstList=unmapped_ptr, rc=rc) - endif + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldRegridStore", rc) @@ -833,28 +819,22 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleCreate", rc) -!if (fract_grid) then - call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_at_ice_target_grid, & + call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_at_ice_target_grid, & snow_liq_equiv_at_ice_target_grid, seaice_skin_temp_target_grid, & ice_temp_target_grid/), rc=rc) -!else -! call ESMF_FieldBundleAdd(bundle_seaice_target, (/seaice_depth_target_grid, snow_depth_target_grid, & -! snow_liq_equiv_target_grid, seaice_skin_temp_target_grid, & -! soil_temp_target_grid/), rc=rc) -!endif - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) call ESMF_FieldBundleAdd(bundle_seaice_input, (/seaice_depth_input_grid, snow_depth_input_grid, & snow_liq_equiv_input_grid, seaice_skin_temp_input_grid, & soil_temp_input_grid/), rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleAdd", rc) + call ESMF_FieldBundleGet(bundle_seaice_target,fieldCount=num_fields,rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleGet", rc) - allocate(search_nums(num_fields)) allocate(dozero(num_fields)) @@ -893,6 +873,7 @@ subroutine interp(localpet) !cfract using ice flag of '2' here. cant do that. if (localpet == 0) then where(mask_target_one_tile == 1) mask_target_one_tile = 0 + print*,'got here ',tile,maxval(mask_target_one_tile),minval(mask_target_one_tile) where(fice_target_one_tile > 0.0) mask_target_one_tile = 1 call search_many(num_fields,bundle_seaice_target,tile, search_nums,localpet, & mask=mask_target_one_tile) @@ -902,7 +883,6 @@ subroutine interp(localpet) enddo - !deallocate(search_nums, fice_target_one_tile) deallocate(search_nums) call ESMF_FieldBundleDestroy(bundle_seaice_target,rc=rc) @@ -2965,8 +2945,6 @@ subroutine create_surface_esmf_fields use model_grid, only : target_grid, lsoil_target - use program_setup, only : fract_grid - implicit none integer :: rc From 481c90baff7ca2dc75f7901732284f01f8d1442a Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 9 Aug 2023 15:04:54 +0000 Subject: [PATCH 070/107] Simplify logic that sets the search mask for sea ice fields. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index cdb1eaec4..d31a78bb5 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -860,20 +860,13 @@ subroutine interp(localpet) do tile = 1, num_tiles_target_grid - print*,"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile - call ESMF_FieldGather(landmask_target_grid, mask_target_one_tile, rootPet=0, tile=tile, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - call error_handler("IN FieldGather", rc) - print*,"- CALL FieldGather FOR TARGET LANDMASK TILE: ", tile call ESMF_FieldGather(seaice_fract_target_grid, fice_target_one_tile, rootPet=0, tile=tile, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) -!cfract using ice flag of '2' here. cant do that. if (localpet == 0) then - where(mask_target_one_tile == 1) mask_target_one_tile = 0 - print*,'got here ',tile,maxval(mask_target_one_tile),minval(mask_target_one_tile) + mask_target_one_tile = 0 where(fice_target_one_tile > 0.0) mask_target_one_tile = 1 call search_many(num_fields,bundle_seaice_target,tile, search_nums,localpet, & mask=mask_target_one_tile) From 3a320b34e7578fe9d8c2c03c41a6c9937a782190 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 9 Aug 2023 18:51:45 +0000 Subject: [PATCH 071/107] Clean up the open water to open water interpolation sections. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 42 +++++++-------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index d31a78bb5..d3bb7adb6 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -318,8 +318,7 @@ subroutine interp(localpet) vgfrc_from_climo, & minmax_vgfrc_from_climo, & lai_from_climo, & - tg3_from_soil, & - fract_grid + tg3_from_soil use static_data, only : veg_type_target_grid, & soil_type_target_grid, & @@ -894,24 +893,18 @@ subroutine interp(localpet) mask_input_ptr = 0 where (nint(landmask_input_ptr) == 0) mask_input_ptr = 1 -!cfract include points that are fractional ice. -!cfract use seamask_target, which is 1 if there is some water. -!cfract then remove points where fice is > 0. -!cfract We want points with at least some water, but no ice. +!--------------------------------------------------------------------------------------------- +! Set target mask - want points with at least some open water. +!--------------------------------------------------------------------------------------------- mask_target_ptr = 0 - where (seamask_target_ptr == 1) mask_target_ptr = 1 - if (fract_grid) then - where (seaice_fract_target_ptr == 1.0_esmf_kind_r8) mask_target_ptr = 0 - else - where (seaice_fract_target_ptr > 0.0) mask_target_ptr = 0 - endif + where (seamask_target_ptr == 1) mask_target_ptr = 1 ! some or all non-land. + where (seaice_fract_target_ptr == 1.0_esmf_kind_r8) mask_target_ptr = 0 ! all ice. method=ESMF_REGRIDMETHOD_CONSERVE isrctermprocessing = 1 print*,"- CALL FieldRegridStore for water fields." -!if(fract_grid)then call ESMF_FieldRegridStore(skin_temp_input_grid, & sst_target_grid, & srcmaskvalues=(/0/), & @@ -923,19 +916,6 @@ subroutine interp(localpet) routehandle=regrid_water, & regridmethod=method, & unmappedDstList=unmapped_ptr, rc=rc) -!else -!call ESMF_FieldRegridStore(skin_temp_input_grid, & -! skin_temp_target_grid, & -! srcmaskvalues=(/0/), & -! dstmaskvalues=(/0/), & -! polemethod=ESMF_POLEMETHOD_NONE, & -! srctermprocessing=isrctermprocessing, & -! unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & -! normtype=ESMF_NORMTYPE_FRACAREA, & -! routehandle=regrid_water, & -! regridmethod=method, & -! unmappedDstList=unmapped_ptr, rc=rc) -!endif if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldRegridStore", rc) @@ -1024,16 +1004,12 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) -!cfract - here mask must be points with some water, but no ice. +! Mask must be points with some water, but no ice. if (localpet == 0) then allocate(water_target_one_tile(i_target,j_target)) water_target_one_tile = 0 - where(mask_target_one_tile == 1) water_target_one_tile = 1 - if(fract_grid) then - where(fice_target_one_tile == 1.0_esmf_kind_r8) water_target_one_tile = 0 - else - where(fice_target_one_tile > 0.0) water_target_one_tile = 0 - endif + where(mask_target_one_tile == 1) water_target_one_tile = 1 ! some or all non-land. + where(fice_target_one_tile == 1.0_esmf_kind_r8) water_target_one_tile = 0 ! all ice call search_many(num_fields,bundle_water_target, tile,search_nums,localpet, & latitude=latitude_one_tile,mask=water_target_one_tile) else From 018349d41c1807d27b07919ce79c0315e97bf0e1 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 9 Aug 2023 19:11:05 +0000 Subject: [PATCH 072/107] Finish cleanup of routine interp. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 36 +++------------------ sorc/chgres_cube.fd/surface_target_data.F90 | 6 ++-- 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index d3bb7adb6..745aca3d6 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -1038,9 +1038,8 @@ subroutine interp(localpet) mask_input_ptr = 0 where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1 -!cfract this logic should work for fractional grids. mask_target_ptr = 0 - where (landmask_target_ptr == 1) mask_target_ptr = 1 + where (landmask_target_ptr == 1) mask_target_ptr = 1 ! some or all land. method=ESMF_REGRIDMETHOD_CONSERVE isrctermprocessing = 1 @@ -1090,7 +1089,6 @@ subroutine interp(localpet) call ESMF_FieldBundleDestroy(bundle_allland_input,rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldBundleDestroy", rc) - do tile = 1, num_tiles_target_grid @@ -1099,11 +1097,10 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) -!cfract 0 - all water; 1 - some land. if (localpet == 0) then allocate(land_target_one_tile(i_target,j_target)) land_target_one_tile = 0 - where(mask_target_one_tile == 1) land_target_one_tile = 1 + where(mask_target_one_tile == 1) land_target_one_tile = 1 ! some or all land. call search_many(num_fields,bundle_allland_target, & tile,search_nums,localpet, mask=land_target_one_tile) @@ -1134,8 +1131,6 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - print*,'land ice check ',veg_type_landice_input - mask_input_ptr = 0 where (nint(veg_type_input_ptr) == veg_type_landice_input) mask_input_ptr = 1 @@ -1145,8 +1140,6 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract veg_type_target should contain a valid value at points with -!cfract any land. So this logic should work with fractional grids. mask_target_ptr = 0 where (nint(veg_type_target_ptr) == veg_type_landice_target) mask_target_ptr = 1 @@ -1232,8 +1225,6 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) -!cfract setting land_target_one_tile. this should work for fractional grids. - if (localpet == 0) then land_target_one_tile = 0 where(nint(veg_type_target_one_tile) == veg_type_landice_target) land_target_one_tile = 1 @@ -1273,10 +1264,9 @@ subroutine interp(localpet) where (nint(landmask_input_ptr) == 1) mask_input_ptr = 1 where (nint(veg_type_input_ptr) == veg_type_landice_input) mask_input_ptr = 0 -!cfract This should work for fractional grid. mask_target_ptr = 0 - where (landmask_target_ptr == 1) mask_target_ptr = 1 - where (nint(veg_type_target_ptr) == veg_type_landice_target) mask_target_ptr = 0 + where (landmask_target_ptr == 1) mask_target_ptr = 1 ! some or all land. + where (nint(veg_type_target_ptr) == veg_type_landice_target) mask_target_ptr = 0 ! land ice. method=ESMF_REGRIDMETHOD_NEAREST_STOD isrctermprocessing = 1 @@ -1316,12 +1306,6 @@ subroutine interp(localpet) if (.not. sotyp_from_climo) then -! call ESMF_FieldBundleAdd(bundle_nolandice_target, (/soil_type_target_grid/), rc=rc) -! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldBundleAdd", rc) -! call ESMF_FieldBundleAdd(bundle_nolandice_input, (/soil_type_input_grid/), rc=rc) -! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldBundleAdd", rc) print*,"- CALL Field_Regrid ." call ESMF_FieldRegrid(soil_type_input_grid, & soil_type_target_grid, & @@ -1343,10 +1327,6 @@ subroutine interp(localpet) call ij_to_i_j(unmapped_ptr(ij), i_target, j_target, i, j) soil_type_target_ptr(i,j) = -9999.9 enddo - ! call ESMF_FieldBundleGet(bundle_nolandice_target,fieldCount=num_fields,rc=rc) - ! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & - ! call error_handler("IN FieldBundleGet", rc) - ! sotyp_ind = 3 endif if (.not. vgfrc_from_climo) then @@ -1407,11 +1387,6 @@ subroutine interp(localpet) search_nums(1:5) = (/85,7,224,85,86/) dozero(1:5) = (/.False.,.False.,.True.,.True.,.False./) - !if (.not.sotyp_from_climo) then - ! search_nums(sotyp_ind) = 226 - ! dozero(sotyp_ind) = .False. - !endif - if (.not. vgfrc_from_climo) then search_nums(vgfrc_ind) = 224 dozero(vgfrc_ind) = .True. @@ -1455,9 +1430,6 @@ subroutine interp(localpet) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGather", rc) -!cfract Here mask_target_one_tile is 'landmask_target_grid'. it is -!cfract then modified by veg_type_target_grid. so this should work for -!cfract grids. if (localpet == 0) then where(nint(veg_type_target_one_tile) == veg_type_landice_target) mask_target_one_tile = 0 endif diff --git a/sorc/chgres_cube.fd/surface_target_data.F90 b/sorc/chgres_cube.fd/surface_target_data.F90 index 1520a5b73..f4f6e0bc8 100644 --- a/sorc/chgres_cube.fd/surface_target_data.F90 +++ b/sorc/chgres_cube.fd/surface_target_data.F90 @@ -40,14 +40,14 @@ module surface_target_data type(esmf_field), public :: srflag_target_grid !< Snow/rain flag. type(esmf_field), public :: snow_liq_equiv_target_grid - !< Liquid equivalent snow depth. + !< Liquid equivalent snow depth at land. type(esmf_field), public :: snow_liq_equiv_at_ice_target_grid !< Liquid equivalent snow depth at sea !< ice. type(esmf_field), public :: snow_depth_target_grid - !< Physical snow depth. + !< Physical snow depth at land. type(esmf_field), public :: snow_depth_at_ice_target_grid - !< physical snow depth at sea ice + !< physical snow depth at sea ice. type(esmf_field), public :: soil_temp_target_grid !< 3-d soil temperature. type(esmf_field), public :: soilm_liq_target_grid From 56c90e04365d0dcd0036b18e857c57f03401b4fe Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 9 Aug 2023 19:59:34 +0000 Subject: [PATCH 073/107] Cleanup routine 'update_landmask'. Fixes #123 --- sorc/chgres_cube.fd/surface.F90 | 59 +++++++++++---------------------- 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 745aca3d6..6041708f7 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -3005,7 +3005,6 @@ subroutine create_surface_esmf_fields target_ptr = init_val -!if (fract_grid) then print*,"- CALL FieldCreate FOR TARGET GRID SNOW LIQ EQUIV AT SEA ICE." snow_liq_equiv_at_ice_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3022,8 +3021,6 @@ subroutine create_surface_esmf_fields target_ptr = init_val -!endif ! fractional grid - print*,"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH." snow_depth_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3040,7 +3037,6 @@ subroutine create_surface_esmf_fields target_ptr = init_val -!if (fract_grid) then print*,"- CALL FieldCreate FOR TARGET GRID SNOW DEPTH AT SEA ICE." snow_depth_at_ice_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3056,7 +3052,6 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr = init_val -!endif print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE FRACTION." seaice_fract_target_grid = ESMF_FieldCreate(target_grid, & @@ -3090,7 +3085,6 @@ subroutine create_surface_esmf_fields target_ptr = init_val -!if(fract_grid)then print*,"- CALL FieldCreate FOR TARGET GRID sst." sst_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3106,7 +3100,6 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr = init_val -!endif print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE SKIN TEMP." seaice_skin_temp_target_grid = ESMF_FieldCreate(target_grid, & @@ -3188,7 +3181,6 @@ subroutine create_surface_esmf_fields target_ptr = init_val -!if (fract_grid)then print*,"- CALL FieldCreate FOR TARGET GRID Z0_ICE." z0_ice_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & @@ -3220,7 +3212,6 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr = init_val -!endif print*,"- CALL FieldCreate FOR INTERPOLATED TARGET GRID TERRAIN." terrain_from_input_grid = ESMF_FieldCreate(target_grid, & @@ -3254,8 +3245,7 @@ subroutine create_surface_esmf_fields target_ptr = init_val -!if(fract_grid)then - print*,"- CALL FieldCreate FOR TARGET GRID sea ice column TEMPERATURE." + print*,"- CALL FieldCreate FOR TARGET GRID SEA ICE COLUMN TEMPERATURE." ice_temp_target_grid = ESMF_FieldCreate(target_grid, & typekind=ESMF_TYPEKIND_R8, & staggerloc=ESMF_STAGGERLOC_CENTER, & @@ -3272,7 +3262,6 @@ subroutine create_surface_esmf_fields call error_handler("IN FieldGet", rc) target_ptr_3d = init_val -!endif print*,"- CALL FieldCreate FOR TARGET GRID SOIL TEMPERATURE." soil_temp_target_grid = ESMF_FieldCreate(target_grid, & @@ -3489,13 +3478,16 @@ end subroutine create_nst_esmf_fields !> Update landmask for sea ice. !! +!! The model requires the landmask record be present. However, the data +!! is recomputed in FV3ATM routine fv3atm_sfc_io.F90 after it is read in. Here, +!! compute it using the same algorithm as the model and output it as +!! a diagnostic. +!! !! @author George Gayno subroutine update_landmask use model_grid, only : landmask_target_grid, land_frac_target_grid - use program_setup, only : fract_grid - implicit none integer :: i, j, rc, clb(2), cub(2) @@ -3518,39 +3510,28 @@ subroutine update_landmask if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - if (.not.fract_grid) then - - where(ice_ptr > 0.0) mask_ptr = 2 - - else ! Fractional grid. The model requires this record be present. However, - ! the data is recomputed in FV3GFS_io.F90 after it is read in. Here, - ! compute it using the same algorithm as the model and output it as - ! a diagnostic. - - print*,"- GET TARGET land fraction." - call ESMF_FieldGet(land_frac_target_grid, & + print*,"- GET TARGET land fraction." + call ESMF_FieldGet(land_frac_target_grid, & computationalLBound=clb, & computationalUBound=cub, & farrayPtr=land_frac_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - do j = clb(2), cub(2) - do i = clb(1), cub(1) + do j = clb(2), cub(2) + do i = clb(1), cub(1) - mask_ptr(i,j) = ceiling(land_frac_ptr(i,j)) - if (mask_ptr(i,j) /= 1) then - if(ice_ptr(i,j) > 0.0) then - mask_ptr(i,j) = 2 - else - mask_ptr(i,j) = 0 - endif + mask_ptr(i,j) = ceiling(land_frac_ptr(i,j)) + if (mask_ptr(i,j) /= 1) then + if(ice_ptr(i,j) > 0.0) then + mask_ptr(i,j) = 2 + else + mask_ptr(i,j) = 0 endif + endif - enddo - enddo - - endif + enddo + enddo end subroutine update_landmask From 9b8bc940299324a2f7f721de8c603d5bfb144d0b Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 10 Aug 2023 14:57:06 +0000 Subject: [PATCH 074/107] Cleanup routine rescale_soil_moisture and nst_land_fill. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 6041708f7..96e858560 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -1582,10 +1582,9 @@ subroutine calc_liq_soil_moisture do i = clb(1), cub(1) !--------------------------------------------------------------------------------------------- -! Check land points that are not permanent land ice. +! Check points with some land (that are not permanent land ice). !--------------------------------------------------------------------------------------------- -!cfract - 1 for at least some land. if (landmask_ptr(i,j) == 1 .and. nint(veg_type_ptr(i,j)) /= veg_type_landice_target) then soil_type = nint(soil_type_ptr(i,j)) @@ -1866,10 +1865,9 @@ subroutine rescale_soil_moisture do i = clb(1), cub(1) !--------------------------------------------------------------------------------------------- -! Check land points that are not permanent land ice. +! Check points with some land (that are not permanent land ice). !--------------------------------------------------------------------------------------------- -!cfract when '1' will contain some land. if (landmask_ptr(i,j) == 1 .and. nint(veg_type_ptr(i,j)) /= veg_type_landice_target) then soilt_target = nint(soil_type_target_ptr(i,j)) @@ -2016,8 +2014,7 @@ subroutine adjust_soilt_for_terrain do j = clb(2), cub(2) do i = clb(1), cub(1) -!cfract at least some land when equal to '1'. - if (landmask_ptr(i,j) == 1) then + if (landmask_ptr(i,j) == 1) then ! partial or all land terrain_diff = abs(terrain_input_ptr(i,j) - terrain_target_ptr(i,j)) if (terrain_diff > 100.0) then do k = clb(3), cub(3) @@ -2781,8 +2778,6 @@ subroutine nst_land_fill use model_grid, only : seamask_target_grid - use program_setup, only : fract_grid - implicit none integer(esmf_kind_i8), pointer :: mask_ptr(:,:) @@ -2834,16 +2829,8 @@ subroutine nst_land_fill if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldGet", rc) -!cfract Setting filler value for tref at ice and land points. -!cfract Under fractional grids skin t is not currently defined. -!cfract So, set to ice temp. - - where(mask_ptr == 0) data_ptr = skint_ptr - if (fract_grid) then - where(fice_ptr > 0.0) data_ptr = frz_ice - else - where(fice_ptr > 0.0) data_ptr = skint_ptr - endif + where(mask_ptr == 0) data_ptr = skint_ptr ! all land + where(fice_ptr > 0.0) data_ptr = frz_ice ! points with some ice ! xz @@ -2853,9 +2840,8 @@ subroutine nst_land_fill if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldGet", rc) -!cfract same as above. - where(mask_ptr == 0) data_ptr = xz_fill - where(fice_ptr > 0.0) data_ptr = xz_fill + where(mask_ptr == 0) data_ptr = xz_fill ! all land + where(fice_ptr > 0.0) data_ptr = xz_fill ! points with some ice do i = 1,num_nst_fields_minus2 @@ -2867,9 +2853,8 @@ subroutine nst_land_fill if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))& call error_handler("IN FieldGet", rc) -!cfract same as above. - where(mask_ptr == 0) data_ptr = nst_fill - where(fice_ptr > 0.0) data_ptr = nst_fill + where(mask_ptr == 0) data_ptr = nst_fill ! all land + where(fice_ptr > 0.0) data_ptr = nst_fill ! points with some ice enddo From 499531351de35239ee4482d448e0fceffe7747b5 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 10 Aug 2023 15:17:22 +0000 Subject: [PATCH 075/107] Cleanup routine 'roughness'. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 89 ++++++++++++--------------------- 1 file changed, 32 insertions(+), 57 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 96e858560..22f4b2b48 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2148,16 +2148,14 @@ subroutine adjust_soil_levels(localpet) end subroutine adjust_soil_levels -!> Set roughness length at land and sea ice. At land, roughness is -!! set from a lookup table based on the vegetation type. At sea ice, -!! roughness is set to 1 cm. +!> Set roughness length at points with some sea ice to 1 cm. +!! Set flag value at points with some or all open water. !! !! @author George Gayno NOAA/EMC subroutine roughness use model_grid, only : landmask_target_grid, & seamask_target_grid - use program_setup, only : fract_grid implicit none @@ -2169,6 +2167,8 @@ subroutine roughness real(esmf_kind_r8), pointer :: data_ptr3(:,:) real(esmf_kind_r8), pointer :: fice_ptr(:,:) + print*,"- SET ROUGHNESS." + print*,"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK." call ESMF_FieldGet(landmask_target_grid, & computationalLBound=clb, & @@ -2183,71 +2183,46 @@ subroutine roughness if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - print*,"- CALL FieldGet FOR TARGET GRID Z0 WATER." - call ESMF_FieldGet(z0_water_target_grid, & + print*,"- CALL FieldGet FOR TARGET GRID Z0 WATER." + call ESMF_FieldGet(z0_water_target_grid, & farrayPtr=data_ptr3, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - print*,"- CALL FieldGet FOR TARGET SEA MASK." - call ESMF_FieldGet(seamask_target_grid, & + print*,"- CALL FieldGet FOR TARGET SEA MASK." + call ESMF_FieldGet(seamask_target_grid, & farrayPtr=seamask_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - - print*,"- CALL FieldGet FOR TARGET GRID Z0 ICE." - call ESMF_FieldGet(z0_ice_target_grid, & + print*,"- CALL FieldGet FOR TARGET GRID Z0 ICE." + call ESMF_FieldGet(z0_ice_target_grid, & farrayPtr=data_ptr2, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) > 0.0) then - data_ptr2(i,j) = 1.0 - else - data_ptr2(i,j) = 1.e20 - endif - enddo - enddo - - if(fract_grid)then - +! At points with some ice, set to nominal value of 1 cm. Elsewhere, set to flag value. -! print*,"- CALL FieldGet FOR TARGET GRID Z0 WATER." -! call ESMF_FieldGet(z0_water_target_grid, & -! farrayPtr=data_ptr3, rc=rc) -! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldGet", rc) - -! print*,"- CALL FieldGet FOR TARGET SEA MASK." -! call ESMF_FieldGet(seamask_target_grid, & -! farrayPtr=seamask_ptr, rc=rc) -! if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & -! call error_handler("IN FieldGet", rc) - - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) == 1.0_esmf_kind_r8 .or. seamask_ptr(i,j) == 0) then - data_ptr3(i,j) = 1.e20 - endif - enddo - enddo + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) > 0.0) then + data_ptr2(i,j) = 1.0 + else + data_ptr2(i,j) = 1.e20 + endif + enddo + enddo - else ! non-fractional grid +! Roughness at points with some or all open water. Here we set a flag value at points +! that are all ice or points that are all land (seamask = 0). -!cfract should check for fice instead? under fractional -!cfract grids need to preserve original landmask_target. - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) > 0.0 .or. seamask_ptr(i,j) == 0) then - data_ptr3(i,j) = 1.e20 - endif - enddo - enddo - - endif + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) == 1.0_esmf_kind_r8 .or. seamask_ptr(i,j) == 0) then + data_ptr3(i,j) = 1.e20 + endif + enddo + enddo end subroutine roughness From 6fdae16182ac35621d18db6c79cdeb7cbeb648c4 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 10 Aug 2023 17:10:00 +0000 Subject: [PATCH 076/107] Begin clean up of routine qc_check. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 129 ++++++++++++-------------------- 1 file changed, 49 insertions(+), 80 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 22f4b2b48..6dc43a6b8 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2280,13 +2280,11 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!if (fract_grid) then - print*,"- CALL FieldGet FOR TARGET GRID SEA MASK." - call ESMF_FieldGet(seamask_target_grid, & - farrayPtr=seamask_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + print*,"- CALL FieldGet FOR TARGET GRID SEA MASK." + call ESMF_FieldGet(seamask_target_grid, & + farrayPtr=seamask_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!endif print*,"- CALL FieldGet FOR TARGET GRID SEA ICE FRACTION." call ESMF_FieldGet(seaice_fract_target_grid, & @@ -2300,9 +2298,8 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract Setting to flag value at water. With fractional grid, -!cfract restrict this to points that are all water. i.e., -!cfract where landmask_ptr = 0. +! Slope type is set to flag value at points that are all non-land. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2315,9 +2312,8 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract Setting to flag value at water. With fractional grid, -!cfract restrict this to points that are all water. i.e., -!cfract where landmask_ptr = 0. +! Soil type is set to flag value at points that are all non-land. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2330,67 +2326,67 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract Setting to flag value at water. With fractional grid, -!cfract restrict this to points that are all water. i.e., -!cfract where landmask_ptr = 0. +! Vegetation type is set to flag value at points that are all non-land. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) veg_type_ptr(i,j) = 0.0 enddo enddo - print*,"- SET TARGET GRID ALVSF AT NON-LAND." + print*,"- SET TARGET GRID ALVSF FLAG AT NON-LAND." call ESMF_FieldGet(alvsf_target_grid, & farrayPtr=data_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract This array contains albedo at points with at least -!cfract some land. At all other points set to flag value. -!cfract That means points where landmask_ptr is 0. +! Set to flag value at points that are all non-land. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value -! if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo - print*,"- SET TARGET GRID ALVWF AT NON-LAND." + print*,"- SET TARGET GRID ALVWF FLAG AT NON-LAND." call ESMF_FieldGet(alvwf_target_grid, & farrayPtr=data_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +! Set to flag value at points that are all non-land. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value -! if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo - print*,"- SET TARGET GRID ALNSF AT NON-LAND." + print*,"- SET TARGET GRID ALNSF FLAG AT NON-LAND." call ESMF_FieldGet(alnsf_target_grid, & farrayPtr=data_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +! Set to flag value at points that are all non-land. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value -! if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo - print*,"- SET TARGET GRID ALNWF AT NON-LAND." + print*,"- SET TARGET GRID ALNWF FLAG AT NON-LAND." call ESMF_FieldGet(alnwf_target_grid, & farrayPtr=data_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +! Set to flag value at points that are all non-land. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value -! if (fract_grid .and. landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2400,7 +2396,6 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract for fract grid, this is where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2413,7 +2408,6 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract for fract grid, this is where landmask_ptr is 0. do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2426,7 +2420,8 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract for fract grid, this is where landmask_ptr is 0. +! Set to flag value at points that are all non-land. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2439,7 +2434,8 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract for fract grid, this is where landmask_ptr is 0. +! Set to flag value at points that are all non-land. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2452,7 +2448,8 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract for fract grid, this is where landmask_ptr is 0. +! Set to flag value at points that are all non-land. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) veg_greenness_ptr(i,j) = 0.0 @@ -2465,7 +2462,8 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!cfract for fract grid, this is where landmask_ptr is 0. +! Set to flag value at points that are all non-land. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 @@ -2478,6 +2476,8 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +! The 0.01 indicates bare ground. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (veg_greenness_ptr(i,j) <= 0.01) data_ptr(i,j) = 0.0 @@ -2490,77 +2490,46 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - print*,"- SET TARGET GRID SKIN TEMP AT ICE POINTS." + print*,"- CALL FieldGet FOR TARGET GRID SKIN TEMP." call ESMF_FieldGet(skin_temp_target_grid, & farrayPtr=skint_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - print*,"- SET TARGET GRID SEA ICE DEPTH TO ZERO AT NON-ICE POINTS." + print*,"- CALL FieldGet FOR TARGET GRID ICE DEPTH." call ESMF_FieldGet(seaice_depth_target_grid, & farrayPtr=hice_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!if(fract_grid)then + print*,"- SET TARGET GRID SEA ICE DEPTH TO ZERO AT NON-ICE POINTS." + do j = clb(2), cub(2) do i = clb(1), cub(1) - if (fice_ptr(i,j) > 0.0) then -! skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + & -! ( (1.0 - fice_ptr(i,j)) * frz_ice ) - else + if (fice_ptr(i,j) == 0.0) then seaice_skint_ptr(i,j) = 1.e20 hice_ptr(i,j) = 0.0 endif enddo enddo -!else -!do j = clb(2), cub(2) -!do i = clb(1), cub(1) -! if (fice_ptr(i,j) > 0.0) then -! skint_ptr(i,j) = (fice_ptr(i,j) * seaice_skint_ptr(i,j)) + & -! ( (1.0 - fice_ptr(i,j)) * frz_ice ) -! else -! seaice_skint_ptr(i,j) = skint_ptr(i,j) -! hice_ptr(i,j) = 0.0 -! endif -!enddo -!enddo -!endif - -!if (fract_grid) then - - print*,"- SET TARGET GRID SST FLAG VALUE." - call ESMF_FieldGet(sst_target_grid, & + print*,"- SET TARGET GRID SST FLAG VALUE." + call ESMF_FieldGet(sst_target_grid, & farrayPtr=data_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - if (fract_grid) then - - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) == 1.0_esmf_kind_r8 .or. seamask_ptr(i,j) == 0.0) then - data_ptr(i,j) = 1.e20 - endif - enddo - enddo - - else - - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) > 0.0 .or. seamask_ptr(i,j) == 0.0) then - data_ptr(i,j) = 1.e20 - endif - enddo - enddo +! Set flag at points with all ice or points that are all land (seamask=0). - endif + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) == 1.0_esmf_kind_r8 .or. seamask_ptr(i,j) == 0.0) then + data_ptr(i,j) = 1.e20 + endif + enddo + enddo print*,"- SET MISSING FLAG AT TARGET GRID SUBSTRATE TEMP." - call ESMF_FieldGet(substrate_temp_target_grid, & farrayPtr=tg3_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2568,7 +2537,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0.0) then ! non-land + if (landmask_ptr(i,j) == 0.0) then ! completely non-land. tg3_ptr(i,j) = -1.e20 endif enddo From 31f1ddcf042757cf028feb2b8064766dc35a39b0 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 10 Aug 2023 17:16:47 +0000 Subject: [PATCH 077/107] Remove 'fract_grid' logical as this code will always assume a fractional grid. Fixes #123. --- sorc/chgres_cube.fd/program_setup.F90 | 13 +------------ sorc/chgres_cube.fd/surface.F90 | 5 +++-- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/sorc/chgres_cube.fd/program_setup.F90 b/sorc/chgres_cube.fd/program_setup.F90 index 8ccc8f26e..1f50492ac 100644 --- a/sorc/chgres_cube.fd/program_setup.F90 +++ b/sorc/chgres_cube.fd/program_setup.F90 @@ -99,10 +99,6 @@ module program_setup logical, public :: convert_sfc = .false. !< Convert sfc data when true. logical, public :: wam_cold_start = .false. !< When true, cold start for whole atmosphere model. - - logical, public :: fract_grid = .false. !< When true, run for coupled grids (where model - !! points can be both land and non-land). - ! Options for replacing vegetation/soil type, veg fraction, and lai with data from the grib2 file ! Default is to use climatology instead logical, public :: vgtyp_from_climo = .true. !< If false, interpolate vegetation type from the input @@ -199,8 +195,7 @@ subroutine read_setup_namelist(filename) halo_bndy, & halo_blend, & nsoill_out, & - thomp_mp_climo_file, & - fract_grid + thomp_mp_climo_file print*,"- READ SETUP NAMELIST" @@ -351,12 +346,6 @@ subroutine read_setup_namelist(filename) print*,"- WILL PROCESS CLIMO THOMPSON MP TRACERS FROM FILE: ", trim(thomp_mp_climo_file) endif - if (fract_grid) then - print*,'WILL PROCESS A FRACTIONAL GRID.' - else - print*,'WILL PROCESS A NON-FRACTIONAL GRID.' - endif - return end subroutine read_setup_namelist diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 6dc43a6b8..59b553c6b 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -223,6 +223,9 @@ subroutine surface_driver(localpet) if (convert_nst) call cleanup_input_nst_data +!--------------------------------------------------------------------------------------------- +! Update land mask for ice. +!--------------------------------------------------------------------------------------------- call update_landmask @@ -2231,8 +2234,6 @@ end subroutine roughness !! @author George Gayno NOAA/EMC subroutine qc_check - use program_setup, only : fract_grid - use model_grid, only : landmask_target_grid, & seamask_target_grid From fe0939d38b6acb37b99fffadb800e1409a41eb42 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 10 Aug 2023 18:55:58 +0000 Subject: [PATCH 078/107] More cleanup to routine qc_check. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 249 +++++++++++--------------------- 1 file changed, 87 insertions(+), 162 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 59b553c6b..7814d46ef 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2229,7 +2229,8 @@ subroutine roughness end subroutine roughness -!> Perform some quality control checks before output. +!> Perform some quality control checks and set flag values +!! at non-active points. !! !! @author George Gayno NOAA/EMC subroutine qc_check @@ -2273,6 +2274,8 @@ subroutine qc_check real(esmf_kind_r8), pointer :: snod_ptr(:,:) real(esmf_kind_r8), pointer :: snol_ptr(:,:) + print*,'- PERFORM QC CHECK' + print*,"- CALL FieldGet FOR TARGET GRID LAND-SEA MASK." call ESMF_FieldGet(landmask_target_grid, & computationalLBound=clb, & @@ -2299,11 +2302,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -! Slope type is set to flag value at points that are all non-land. - do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = 0.0 ! all non-land. enddo enddo @@ -2313,11 +2314,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -! Soil type is set to flag value at points that are all non-land. - do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = 0.0 ! all non-land. enddo enddo @@ -2327,11 +2326,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -! Vegetation type is set to flag value at points that are all non-land. - do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) veg_type_ptr(i,j) = 0.0 + if (landmask_ptr(i,j) == 0) veg_type_ptr(i,j) = 0.0 ! all non-land. enddo enddo @@ -2341,11 +2338,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -! Set to flag value at points that are all non-land. - do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2355,11 +2350,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -! Set to flag value at points that are all non-land. - do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2369,11 +2362,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -! Set to flag value at points that are all non-land. - do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2383,11 +2374,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -! Set to flag value at points that are all non-land. - do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = -1.e20 ! gfs physics flag value enddo enddo @@ -2399,7 +2388,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = 0.0 ! all non-land enddo enddo @@ -2411,7 +2400,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = 0.0 ! all non-land enddo enddo @@ -2421,11 +2410,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -! Set to flag value at points that are all non-land. - do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = 0.0 ! all non-land enddo enddo @@ -2435,11 +2422,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -! Set to flag value at points that are all non-land. - do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = 0.0 ! all non-land enddo enddo @@ -2449,11 +2434,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -! Set to flag value at points that are all non-land. - do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) veg_greenness_ptr(i,j) = 0.0 + if (landmask_ptr(i,j) == 0) veg_greenness_ptr(i,j) = 0.0 ! all non-land enddo enddo @@ -2463,11 +2446,9 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -! Set to flag value at points that are all non-land. - do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) data_ptr(i,j) = 0.0 + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = 0.0 ! all non-land enddo enddo @@ -2544,86 +2525,56 @@ subroutine qc_check enddo enddo -!if (fract_grid) then + print*,"- SET MISSING FLAG AT TARGET GRID SNOW FIELDS AT ICE." - print*,"- SET MISSING FLAG AT TARGET GRID SNOW DEPTH AT ICE." - call ESMF_FieldGet(snow_depth_at_ice_target_grid, & + print*,"- CALL FieldGet FOR TARGET GRID SNOW DEPTH AT ICE." + call ESMF_FieldGet(snow_depth_at_ice_target_grid, & farrayPtr=snod_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - print*,"- SET MISSING FLAG AT TARGET GRID SNOW LIQ EQUIV AT ICE." - call ESMF_FieldGet(snow_liq_equiv_at_ice_target_grid, & - farrayPtr=snol_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + print*,"- CALL FieldGet FOR TARGET GRID SNOW LIQ EQUIV AT ICE." + call ESMF_FieldGet(snow_liq_equiv_at_ice_target_grid, & + farrayPtr=snol_ptr, rc=rc) + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) == 0.0) then - snol_ptr(i,j) = 1.e20 - snod_ptr(i,j) = 1.e20 - end if - enddo - enddo - -!endif + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) == 0.0) then ! points with no ice. + snol_ptr(i,j) = 1.e20 + snod_ptr(i,j) = 1.e20 + end if + enddo + enddo - print*,"- ZERO OUT TARGET GRID SNOW DEPTH AT OPEN WATER." + print*,"- ZERO OUT TARGET GRID SNOW DEPTH AT NON-LAND." call ESMF_FieldGet(snow_depth_target_grid, & farrayPtr=data_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!if (fract_grid) then - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) then ! not land -! if (fice_ptr(i,j) > 0.0) then -! data_ptr(i,j) = snod_ptr(i,j) -! else - data_ptr(i,j) = 1.e20 -! endif - end if - enddo - enddo -!else -! do j = clb(2), cub(2) -! do i = clb(1), cub(1) -! if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then -! data_ptr(i,j) = 0.0 -! end if -! enddo -! enddo -!endif - - print*,"- ZERO OUT TARGET GRID SNOW LIQ AT OPEN WATER." + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0) then ! all non-land + data_ptr(i,j) = 1.e20 + end if + enddo + enddo + + print*,"- ZERO OUT TARGET GRID SNOW LIQ AT NON-LAND." call ESMF_FieldGet(snow_liq_equiv_target_grid, & farrayPtr=data_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!if (fract_grid) then - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) /= 1) then ! not land - ! if (fice_ptr(i,j) > 0.0) then - ! data_ptr(i,j) = snol_ptr(i,j) - ! else - data_ptr(i,j) = 1.e20 - ! endif - end if - enddo - enddo -!else -! do j = clb(2), cub(2) -! do i = clb(1), cub(1) -! if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then -! data_ptr(i,j) = 0.0 -! end if -! enddo -! enddo -!endif + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0) then ! all non-land + data_ptr(i,j) = 1.e20 + end if + enddo + enddo print*,"- SET NON-LAND FLAG VALUE FOR TARGET GRID TOTAL SOIL MOISTURE." call ESMF_FieldGet(soilm_tot_target_grid, & @@ -2631,85 +2582,59 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - print*,"- SET NON-LAND FLAG VALUE FOR TARGET GRID LIQUID SOIL MOISTURE." + print*,"- SET NON-LAND FLAG VALUE FOR TARGET GRID LIQUID SOIL MOISTURE." call ESMF_FieldGet(soilm_liq_target_grid, & farrayPtr=soilml_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!if (fract_grid) then - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0 .or. & - nint(veg_type_ptr(i,j)) == veg_type_landice_target) then - soilmt_ptr(i,j,:) = 1.0 - soilml_ptr(i,j,:) = 1.0 - endif - enddo - enddo -!else -! do j = clb(2), cub(2) -! do i = clb(1), cub(1) -! if (fice_ptr(i,j) > 0.0 .or. landmask_ptr(i,j) == 0 .or. & -! nint(veg_type_ptr(i,j)) == veg_type_landice_target) then -! soilmt_ptr(i,j,:) = 1.0 -! soilml_ptr(i,j,:) = 1.0 -! endif -! enddo -! enddo -!endif - - print*,"- SET OPEN WATER FLAG FOR TARGET GRID SOIL TEMPERATURE." + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0 .or. & + nint(veg_type_ptr(i,j)) == veg_type_landice_target) then + soilmt_ptr(i,j,:) = 1.0 + soilml_ptr(i,j,:) = 1.0 + endif + enddo + enddo + + print*,"- SET NON-LAND FLAG FOR TARGET GRID SOIL TEMPERATURE." call ESMF_FieldGet(soil_temp_target_grid, & farrayPtr=data3d_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) -!if (fract_grid) then - - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0) then - data3d_ptr(i,j,:) = -1.e20 - endif - enddo - enddo + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0) then ! all non-land. + data3d_ptr(i,j,:) = -1.e20 + endif + enddo + enddo - print*,"- SET FLAG FOR TARGET GRID ICE TEMPERATURE." - call ESMF_FieldGet(ice_temp_target_grid, & + print*,"- SET NON-ICE FLAG FOR TARGET GRID ICE TEMPERATURE." + call ESMF_FieldGet(ice_temp_target_grid, & farrayPtr=ice_ptr, rc=rc) - if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & + if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (fice_ptr(i,j) == 0.0) then - ice_ptr(i,j,:) = 1.e20 - endif - enddo - enddo - -!else - -!do j = clb(2), cub(2) -!do i = clb(1), cub(1) -! if (landmask_ptr(i,j) == 0 .and. fice_ptr(i,j) == 0.0) then -! data3d_ptr(i,j,:) = skint_ptr(i,j) ! open water flag value. -! endif -!enddo -!enddo + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (fice_ptr(i,j) == 0.0) then + ice_ptr(i,j,:) = 1.e20 + endif + enddo + enddo -!endif + print*,"- SET NON-LAND FLAG FOR TARGET GRID SKIN TEMPERATURE." -!if (fract_grid) then ! set flag value at non-land - do j = clb(2), cub(2) - do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0) then - skint_ptr(i,j) = 1.e20 - endif - enddo - enddo -!endif + do j = clb(2), cub(2) + do i = clb(1), cub(1) + if (landmask_ptr(i,j) == 0) then ! all non-land. + skint_ptr(i,j) = 1.e20 + endif + enddo + enddo return From a00b322d005d4864b6066f744895ead117ef08d7 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 10 Aug 2023 19:08:48 +0000 Subject: [PATCH 079/107] Minor update to print statements. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 7814d46ef..857b73eb1 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2548,7 +2548,7 @@ subroutine qc_check enddo enddo - print*,"- ZERO OUT TARGET GRID SNOW DEPTH AT NON-LAND." + print*,"- SET NON-LAND FLAG AT TARGET GRID SNOW DEPTH." call ESMF_FieldGet(snow_depth_target_grid, & farrayPtr=data_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & @@ -2562,7 +2562,7 @@ subroutine qc_check enddo enddo - print*,"- ZERO OUT TARGET GRID SNOW LIQ AT NON-LAND." + print*,"- SET NON-LAND FLAG AT TARGET GRID SNOW LIQ." call ESMF_FieldGet(snow_liq_equiv_target_grid, & farrayPtr=data_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & From 6dbe3e7bb9435bba637c3bb12e32735fd98f6de4 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 11 Aug 2023 18:52:02 +0000 Subject: [PATCH 080/107] Standardize the 'missing' flag for non-active points. Add 'missing' attribute to surface coldstart file. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 35 +++++++++++++------------ sorc/chgres_cube.fd/write_data.F90 | 41 +++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 20 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 857b73eb1..cde6f886d 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -80,6 +80,9 @@ module surface !< gravity real, parameter, private :: hlice = 3.335E5 !< latent heat of fusion + + real(esmf_kind_r8), parameter, private :: missing = -1.e20_esmf_kind_r8 + !< flag for non-active points. type realptr_2d @@ -2211,7 +2214,7 @@ subroutine roughness if (fice_ptr(i,j) > 0.0) then data_ptr2(i,j) = 1.0 else - data_ptr2(i,j) = 1.e20 + data_ptr2(i,j) = missing endif enddo enddo @@ -2222,7 +2225,7 @@ subroutine roughness do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 1.0_esmf_kind_r8 .or. seamask_ptr(i,j) == 0) then - data_ptr3(i,j) = 1.e20 + data_ptr3(i,j) = missing endif enddo enddo @@ -2340,7 +2343,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = missing ! gfs physics flag value enddo enddo @@ -2352,7 +2355,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = missing ! gfs physics flag value enddo enddo @@ -2364,7 +2367,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = missing ! gfs physics flag value enddo enddo @@ -2376,7 +2379,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) - if (landmask_ptr(i,j) == 0) data_ptr(i,j) = -1.e20 ! gfs physics flag value + if (landmask_ptr(i,j) == 0) data_ptr(i,j) = missing ! gfs physics flag value enddo enddo @@ -2489,7 +2492,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 0.0) then - seaice_skint_ptr(i,j) = 1.e20 + seaice_skint_ptr(i,j) = missing hice_ptr(i,j) = 0.0 endif enddo @@ -2506,7 +2509,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 1.0_esmf_kind_r8 .or. seamask_ptr(i,j) == 0.0) then - data_ptr(i,j) = 1.e20 + data_ptr(i,j) = missing endif enddo enddo @@ -2520,7 +2523,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0.0) then ! completely non-land. - tg3_ptr(i,j) = -1.e20 + tg3_ptr(i,j) = missing endif enddo enddo @@ -2542,8 +2545,8 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 0.0) then ! points with no ice. - snol_ptr(i,j) = 1.e20 - snod_ptr(i,j) = 1.e20 + snol_ptr(i,j) = missing + snod_ptr(i,j) = missing end if enddo enddo @@ -2557,7 +2560,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0) then ! all non-land - data_ptr(i,j) = 1.e20 + data_ptr(i,j) = missing end if enddo enddo @@ -2571,7 +2574,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0) then ! all non-land - data_ptr(i,j) = 1.e20 + data_ptr(i,j) = missing end if enddo enddo @@ -2607,7 +2610,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0) then ! all non-land. - data3d_ptr(i,j,:) = -1.e20 + data3d_ptr(i,j,:) = missing endif enddo enddo @@ -2621,7 +2624,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 0.0) then - ice_ptr(i,j,:) = 1.e20 + ice_ptr(i,j,:) = missing endif enddo enddo @@ -2631,7 +2634,7 @@ subroutine qc_check do j = clb(2), cub(2) do i = clb(1), cub(1) if (landmask_ptr(i,j) == 0) then ! all non-land. - skint_ptr(i,j) = 1.e20 + skint_ptr(i,j) = missing endif enddo enddo diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index d1c4b8181..825d57267 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1908,6 +1908,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet) real(kind=4), allocatable :: lsoil_data(:), x_data(:), y_data(:) real(kind=8), allocatable :: dum2d(:,:), dum3d(:,:,:) real(kind=4) :: times + real(kind=8), parameter :: missing=-1.e+20_8 real(esmf_kind_r8), allocatable :: data_one_tile(:,:) real(esmf_kind_r8), allocatable :: data_one_tile_3d(:,:,:) @@ -2059,6 +2060,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING TSFCL UNITS' ) error = nf90_put_att(ncid, id_tsfcl, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TSFCL COORD' ) + error = nf90_put_att(ncid, id_tsfcl, "missing_value", missing) + call netcdf_err(error, 'DEFINING TSFCL MISSING FLAG' ) error = nf90_def_var(ncid, 'tsea', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tsea) call netcdf_err(error, 'DEFINING TSEA' ) @@ -2068,6 +2071,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING TSEA UNITS' ) error = nf90_put_att(ncid, id_tsea, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TSEA COORD' ) + error = nf90_put_att(ncid, id_tsea, "missing_value", missing) + call netcdf_err(error, 'DEFINING TSEA MISSING FLAG' ) error = nf90_def_var(ncid, 'weasdi', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_ice) call netcdf_err(error, 'DEFINING WEASD/SHELEG AT ICE' ) @@ -2077,6 +2082,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING WEASD/SHELEG AT ICE UNITS' ) error = nf90_put_att(ncid, id_sheleg_ice, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING WEASD/SHELEG AT ICE COORD' ) + error = nf90_put_att(ncid, id_sheleg_ice, "missing_value", missing) + call netcdf_err(error, 'DEFINING WEASD/SHELEG AT ICE MISSING FLAG' ) error = nf90_def_var(ncid, 'weasdl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_sheleg_land) call netcdf_err(error, 'DEFINING WEASD/SHELEG AT LAND' ) @@ -2086,6 +2093,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING WEASD/SHELEG AT LAND UNITS' ) error = nf90_put_att(ncid, id_sheleg_land, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SHELEG AT LAND COORD' ) + error = nf90_put_att(ncid, id_sheleg_land, "missing_value", missing) + call netcdf_err(error, 'DEFINING SHELEG AT LAND MISSING FLAG' ) error = nf90_def_var(ncid, 'tg3', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3) call netcdf_err(error, 'DEFINING TG3' ) @@ -2095,6 +2104,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING TG3 UNITS' ) error = nf90_put_att(ncid, id_tg3, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TG3 COORD' ) + error = nf90_put_att(ncid, id_tg3, "missing_value", missing) + call netcdf_err(error, 'DEFINING TG3 MISSING FLAG' ) error = nf90_def_var(ncid, 'zorli', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_ice) call netcdf_err(error, 'DEFINING ZORLI' ) @@ -2104,6 +2115,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ZORLI UNITS' ) error = nf90_put_att(ncid, id_zorl_ice, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ZORLI COORD' ) + error = nf90_put_att(ncid, id_zorl_ice, "missing_value", missing) + call netcdf_err(error, 'DEFINING ZORLI MISSING FLAG' ) error = nf90_def_var(ncid, 'zorlw', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_zorl_water) call netcdf_err(error, 'DEFINING ZORLW' ) @@ -2113,6 +2126,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ZORLW UNITS' ) error = nf90_put_att(ncid, id_zorl_water, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ZORLW COORD' ) + error = nf90_put_att(ncid, id_zorl_water, "missing_value", missing) + call netcdf_err(error, 'DEFINING ZORLW MISSING FLAG' ) error = nf90_def_var(ncid, 'alvsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvsf) call netcdf_err(error, 'DEFINING ALVSF' ) @@ -2122,6 +2137,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ALVSF UNITS' ) error = nf90_put_att(ncid, id_alvsf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALVSF COORD' ) + error = nf90_put_att(ncid, id_alvsf, "missing_value", missing) + call netcdf_err(error, 'DEFINING ALVSF MISSING FLAG' ) error = nf90_def_var(ncid, 'alvwf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alvwf) call netcdf_err(error, 'DEFINING ALVWF' ) @@ -2131,6 +2148,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ALVWF UNITS' ) error = nf90_put_att(ncid, id_alvwf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALVWF COORD' ) + error = nf90_put_att(ncid, id_alvwf, "missing_value", missing) + call netcdf_err(error, 'DEFINING ALVWF MISSING FLAG' ) error = nf90_def_var(ncid, 'alnsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnsf) call netcdf_err(error, 'DEFINING ALNSF' ) @@ -2140,6 +2159,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ALNSF UNITS' ) error = nf90_put_att(ncid, id_alnsf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALNSF COORD' ) + error = nf90_put_att(ncid, id_alnsf, "missing_value", missing) + call netcdf_err(error, 'DEFINING ALNSF MISSING FLAG' ) error = nf90_def_var(ncid, 'alnwf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_alnwf) call netcdf_err(error, 'DEFINING ALNWF' ) @@ -2149,6 +2170,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING ALNWF UNITS' ) error = nf90_put_att(ncid, id_alnwf, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING ALNWF COORD' ) + error = nf90_put_att(ncid, id_alnwf, "missing_value", missing) + call netcdf_err(error, 'DEFINING ALNWF MISSING FLAG' ) error = nf90_def_var(ncid, 'facsf', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_facsf) call netcdf_err(error, 'DEFINING FACSF' ) @@ -2284,6 +2307,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING TISFC UNITS' ) error = nf90_put_att(ncid, id_tisfc, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TISFC COORD' ) + error = nf90_put_att(ncid, id_tisfc, "missing_value", missing) + call netcdf_err(error, 'DEFINING TISFC MISSING FLAG' ) error = nf90_def_var(ncid, 'tprcp', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tprcp) call netcdf_err(error, 'DEFINING TPRCP' ) @@ -2311,15 +2336,19 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING SNWDPH AT ICE UNITS' ) error = nf90_put_att(ncid, id_snwdph_ice, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING SNWDPH AT ICE COORD' ) + error = nf90_put_att(ncid, id_snwdph_ice, "missing_value", missing) + call netcdf_err(error, 'DEFINING SNWDPH AT ICE MISSING FLAG' ) error = nf90_def_var(ncid, 'snodl', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_snwdph_land) - call netcdf_err(error, 'DEFINING SNWDPH AT ICE' ) + call netcdf_err(error, 'DEFINING SNWDPH AT LAND' ) error = nf90_put_att(ncid, id_snwdph_land, "long_name", "snwdph_land") - call netcdf_err(error, 'DEFINING SNWDPH AT ICE LONG NAME' ) + call netcdf_err(error, 'DEFINING SNWDPH AT LAND LONG NAME' ) error = nf90_put_att(ncid, id_snwdph_land, "units", "none") - call netcdf_err(error, 'DEFINING SNWDPH AT ICE UNITS' ) + call netcdf_err(error, 'DEFINING SNWDPH AT LAND UNITS' ) error = nf90_put_att(ncid, id_snwdph_land, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING SNWDPH AT ICE COORD' ) + call netcdf_err(error, 'DEFINING SNWDPH AT LAND COORD' ) + error = nf90_put_att(ncid, id_snwdph_land, "missing_value", missing) + call netcdf_err(error, 'DEFINING SNWDPH AT LAND MISSING FLAG' ) error = nf90_def_var(ncid, 'shdmin', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_shdmin) call netcdf_err(error, 'DEFINING SHDMIN' ) @@ -2376,6 +2405,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING STC UNITS' ) error = nf90_put_att(ncid, id_stc, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING STC COORD' ) + error = nf90_put_att(ncid, id_stc, "missing_value", missing) + call netcdf_err(error, 'DEFINING STC MISSING FLAG' ) error = nf90_def_var(ncid, 'smc', NF90_DOUBLE, (/dim_x,dim_y,dim_lsoil,dim_time/), id_smc) call netcdf_err(error, 'DEFINING SMC' ) @@ -2403,6 +2434,8 @@ subroutine write_fv3_sfc_data_netcdf(localpet) call netcdf_err(error, 'DEFINING TIICE UNITS' ) error = nf90_put_att(ncid, id_ice_temp, "coordinates", "geolon geolat") call netcdf_err(error, 'DEFINING TIICE COORD' ) + error = nf90_put_att(ncid, id_ice_temp, "missing_value", missing) + call netcdf_err(error, 'DEFINING TIICE MISSING FLAG' ) if (convert_nst) then From c3b4bd7c953d4201f3762df7ac45741eb0a31b55 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Tue, 22 Aug 2023 19:32:51 +0000 Subject: [PATCH 081/107] Force sfc_climo_gen to always map to points with at least some land. Fixes #123. --- sorc/sfc_climo_gen.fd/model_grid.F90 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sorc/sfc_climo_gen.fd/model_grid.F90 b/sorc/sfc_climo_gen.fd/model_grid.F90 index abc6b4b37..b2c8f8fc4 100644 --- a/sorc/sfc_climo_gen.fd/model_grid.F90 +++ b/sorc/sfc_climo_gen.fd/model_grid.F90 @@ -370,16 +370,16 @@ subroutine get_model_info(orog_file, mask, land_frac, lat2d, lon2d, idim, jdim) ! surface data will not be mapped to it. !----------------------------------------------------------------------- - error=nf90_inq_varid(ncid, 'lake_frac', id_var) - if (error /= 0) then - print*,"- READ LAND MASK (SLMSK)" - error=nf90_inq_varid(ncid, 'slmsk', id_var) - call netcdf_err(error, "READING SLMSK ID") - error=nf90_get_var(ncid, id_var, dummy) - call netcdf_err(error, "READING SLMSK") - mask = nint(dummy) - land_frac = -999. - else +!error=nf90_inq_varid(ncid, 'lake_frac', id_var) +!if (error /= 0) then +! print*,"- READ LAND MASK (SLMSK)" +! error=nf90_inq_varid(ncid, 'slmsk', id_var) +! call netcdf_err(error, "READING SLMSK ID") +! error=nf90_get_var(ncid, id_var, dummy) +! call netcdf_err(error, "READING SLMSK") +! mask = nint(dummy) +! land_frac = -999. +!else print*,"- READ LAND FRACTION" error=nf90_inq_varid(ncid, 'land_frac', id_var) call netcdf_err(error, "READING LAND_FRAC ID") @@ -393,7 +393,7 @@ subroutine get_model_info(orog_file, mask, land_frac, lat2d, lon2d, idim, jdim) endif enddo enddo - endif +!endif print*,"- READ LATITUDE" error=nf90_inq_varid(ncid, 'geolat', id_var) From 0e4f053b5958552f65942109295455c4f613a6a1 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 23 Aug 2023 11:55:52 +0000 Subject: [PATCH 082/107] Bug fix the ftst_surface_nst_landfill.F90 regression test. Fixes #123. --- tests/chgres_cube/ftst_surface_nst_landfill.F90 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/chgres_cube/ftst_surface_nst_landfill.F90 b/tests/chgres_cube/ftst_surface_nst_landfill.F90 index 3c64b3b18..3228202bb 100644 --- a/tests/chgres_cube/ftst_surface_nst_landfill.F90 +++ b/tests/chgres_cube/ftst_surface_nst_landfill.F90 @@ -13,8 +13,6 @@ program surface_nst_landfill use surface, only : nst_land_fill, & create_nst_esmf_fields - - use program_setup, only : fract_grid use surface_target_data, only : skin_temp_target_grid, & seaice_fract_target_grid, & @@ -82,8 +80,6 @@ program surface_nst_landfill !--------------------------------------------------------------------! !---------------- Setup Target Grid & Coordinates -------------------! !--------------------------------------------------------------------! - - fract_grid = .false. i_target = IPTS_TARGET j_target = JPTS_TARGET From 24fe48a9cb1919e4527221f177d35765049e85d6 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 13 Sep 2023 13:40:33 +0000 Subject: [PATCH 083/107] Add global attribute to surface file to indicate it is from the fractional grid version of chgres. The forecast model will read this file. Fixes #123. --- sorc/chgres_cube.fd/write_data.F90 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 825d57267..8ec2fd833 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1983,6 +1983,13 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_def_dim(ncid, 'Time', 1, dim_time) call netcdf_err(error, 'DEFINING TIME DIMENSION' ) +!--- define attributes +! +!--- The fractional grid version of chgres will output +!--- a new coldstart file. This file will be 'version 2'. + error = nf90_put_att(ncid, nf90_global, 'file_version', 'V2') + call netcdf_err(error, 'DEFINING GLOBAL ATTRIBUTE' ) + !--- define fields error = nf90_def_var(ncid, 'xaxis_1', NF90_FLOAT, (/dim_x/), id_x) call netcdf_err(error, 'DEFINING XAXIS_1 FIELD' ) From 27a549730ab7f611e6161cde497b576fd0429c86 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 30 Oct 2023 20:21:10 +0000 Subject: [PATCH 084/107] Updates to use surface fixed data from a fractional or non-fractional directory. Fixes #123. --- sorc/chgres_cube.fd/program_setup.F90 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sorc/chgres_cube.fd/program_setup.F90 b/sorc/chgres_cube.fd/program_setup.F90 index 1f50492ac..8bfbf4890 100644 --- a/sorc/chgres_cube.fd/program_setup.F90 +++ b/sorc/chgres_cube.fd/program_setup.F90 @@ -38,7 +38,7 @@ module program_setup character(len=500), public :: sfc_files_input_grid(6) = "NULL" !< File names containing input surface data. Not used for 'grib2' input type. character(len=500), public :: vcoord_file_target_grid = "NULL" !< Vertical coordinate definition file. character(len=500), public :: thomp_mp_climo_file= "NULL" !< Path/name to the Thompson MP climatology file. - character(len=6), public :: cres_target_grid = "NULL" !< Target grid resolution, i.e., C768. + character(len=12), public :: cres_target_grid = "NULL" !< Target grid resolution, i.e., C768. character(len=500), public :: atm_weight_file="NULL" !< File containing pre-computed weights to horizontally interpolate atmospheric fields. character(len=25), public :: input_type="restart" !< Input data type: !! - "restart" for fv3 tiled warm restart @@ -160,7 +160,6 @@ subroutine read_setup_namelist(filename) integer :: is, ie, ierr - namelist /config/ varmap_file, & mosaic_file_target_grid, & fix_dir_target_grid, & @@ -220,14 +219,14 @@ subroutine read_setup_namelist(filename) ! Determine CRES of target grid from the name of the mosaic file. !------------------------------------------------------------------------- - is = index(mosaic_file_target_grid, "/", .true.) - ie = index(mosaic_file_target_grid, "mosaic") - 1 + is = index(orog_files_target_grid(1), "C") + ie = index(orog_files_target_grid(1), "_") - 1 if (is == 0 .or. ie == 0) then call error_handler("CANT DETERMINE CRES FROM MOSAIC FILE.", 1) endif - - cres_target_grid = mosaic_file_target_grid(is+1:ie-1) + + cres_target_grid = orog_files_target_grid(1)(is:ie) if (.not. convert_sfc .and. .not. convert_atm) then call error_handler("MUST CONVERT EITHER AN ATM OR SFC FILE.", 1) From 70b1ab468bbd7bceccb8608d0e084728c019a2e7 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 2 Nov 2023 17:58:40 +0000 Subject: [PATCH 085/107] At open water (potential ice points) set TISFC and TIICE to a flag value of 271.2 Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index fe5095a4b..7db6b9063 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -2487,12 +2487,20 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +! Under some model configurations, ice can form at t=00. New ice needs +! a valid skin temperature. Therefore, at open water (potential +! ice points) set to 'frz_ice'. + print*,"- SET TARGET GRID SEA ICE DEPTH TO ZERO AT NON-ICE POINTS." do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 0.0) then - seaice_skint_ptr(i,j) = missing + if (seamask_ptr(i,j) == 0) then ! all land + seaice_skint_ptr(i,j) = missing + else + seaice_skint_ptr(i,j) = frz_ice ! some water and no ice + endif hice_ptr(i,j) = 0.0 endif enddo @@ -2621,10 +2629,18 @@ subroutine qc_check if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & call error_handler("IN FieldGet", rc) +! Under some model configurations, ice can form at t=00. New ice needs +! a valid ice column temperature. Therefore, at open water (potential +! ice points) set to 'frz_ice'. + do j = clb(2), cub(2) do i = clb(1), cub(1) if (fice_ptr(i,j) == 0.0) then - ice_ptr(i,j,:) = missing + if (seamask_ptr(i,j) == 0) then ! all land + ice_ptr(i,j,:) = missing + else + ice_ptr(i,j,:) = frz_ice ! some water and no ice + endif endif enddo enddo From 6db6128e7d9a08b4b1a70b4d72a2cb8902207e96 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 4 Jan 2024 19:37:22 +0000 Subject: [PATCH 086/107] Revert ./sfc_climo_gen.fd/model_grid.F90 to match 'develop'. Fixes #123. --- sorc/sfc_climo_gen.fd/model_grid.F90 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sorc/sfc_climo_gen.fd/model_grid.F90 b/sorc/sfc_climo_gen.fd/model_grid.F90 index b2c8f8fc4..abc6b4b37 100644 --- a/sorc/sfc_climo_gen.fd/model_grid.F90 +++ b/sorc/sfc_climo_gen.fd/model_grid.F90 @@ -370,16 +370,16 @@ subroutine get_model_info(orog_file, mask, land_frac, lat2d, lon2d, idim, jdim) ! surface data will not be mapped to it. !----------------------------------------------------------------------- -!error=nf90_inq_varid(ncid, 'lake_frac', id_var) -!if (error /= 0) then -! print*,"- READ LAND MASK (SLMSK)" -! error=nf90_inq_varid(ncid, 'slmsk', id_var) -! call netcdf_err(error, "READING SLMSK ID") -! error=nf90_get_var(ncid, id_var, dummy) -! call netcdf_err(error, "READING SLMSK") -! mask = nint(dummy) -! land_frac = -999. -!else + error=nf90_inq_varid(ncid, 'lake_frac', id_var) + if (error /= 0) then + print*,"- READ LAND MASK (SLMSK)" + error=nf90_inq_varid(ncid, 'slmsk', id_var) + call netcdf_err(error, "READING SLMSK ID") + error=nf90_get_var(ncid, id_var, dummy) + call netcdf_err(error, "READING SLMSK") + mask = nint(dummy) + land_frac = -999. + else print*,"- READ LAND FRACTION" error=nf90_inq_varid(ncid, 'land_frac', id_var) call netcdf_err(error, "READING LAND_FRAC ID") @@ -393,7 +393,7 @@ subroutine get_model_info(orog_file, mask, land_frac, lat2d, lon2d, idim, jdim) endif enddo enddo -!endif + endif print*,"- READ LATITUDE" error=nf90_inq_varid(ncid, 'geolat', id_var) From cbcf611cb9ef9d4869418ff8a7ce43c962242260 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 4 Jan 2024 19:56:31 +0000 Subject: [PATCH 087/107] Minor cleanup to ./chgres_cube.fd/model_grid.F90 Fixes #123. --- sorc/chgres_cube.fd/model_grid.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorc/chgres_cube.fd/model_grid.F90 b/sorc/chgres_cube.fd/model_grid.F90 index d18529316..44431f59c 100644 --- a/sorc/chgres_cube.fd/model_grid.F90 +++ b/sorc/chgres_cube.fd/model_grid.F90 @@ -1406,7 +1406,6 @@ subroutine get_model_mask_terrain(orog_file, idim, jdim, mask, terrain, land_fra call netcdf_err(error, 'reading orog_raw') land_frac = dummy -!print*,'land frac ',dummy(idim/2,:) error = nf90_close(ncid) deallocate (dummy) @@ -1438,6 +1437,7 @@ subroutine cleanup_input_target_grid_data if (ESMF_FieldIsCreated(longitude_w_input_grid)) then call ESMF_FieldDestroy(longitude_w_input_grid, rc=rc) endif + call ESMF_FieldDestroy(land_frac_target_grid, rc=rc) call ESMF_FieldDestroy(landmask_target_grid, rc=rc) call ESMF_FieldDestroy(latitude_target_grid, rc=rc) if (ESMF_FieldIsCreated(latitude_s_target_grid)) then From 870275f097984884f067d86022c6e421c16b9fcc Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 4 Jan 2024 20:39:07 +0000 Subject: [PATCH 088/107] Update error messaging in write_data.F90. Fixes #123. --- sorc/chgres_cube.fd/write_data.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index 8ec2fd833..61bb7f591 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -2099,9 +2099,9 @@ subroutine write_fv3_sfc_data_netcdf(localpet) error = nf90_put_att(ncid, id_sheleg_land, "units", "none") call netcdf_err(error, 'DEFINING WEASD/SHELEG AT LAND UNITS' ) error = nf90_put_att(ncid, id_sheleg_land, "coordinates", "geolon geolat") - call netcdf_err(error, 'DEFINING SHELEG AT LAND COORD' ) + call netcdf_err(error, 'DEFINING WEASD/SHELEG AT LAND COORD' ) error = nf90_put_att(ncid, id_sheleg_land, "missing_value", missing) - call netcdf_err(error, 'DEFINING SHELEG AT LAND MISSING FLAG' ) + call netcdf_err(error, 'DEFINING WEASD/SHELEG AT LAND MISSING FLAG' ) error = nf90_def_var(ncid, 'tg3', NF90_DOUBLE, (/dim_x,dim_y,dim_time/), id_tg3) call netcdf_err(error, 'DEFINING TG3' ) From a31a0003d02558277456f7963d9569cdc5e3e8f0 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 5 Jan 2024 15:10:10 +0000 Subject: [PATCH 089/107] Minor diagnostic print updates. Fixes #123. --- sorc/chgres_cube.fd/surface.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 7db6b9063..68a9d131a 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -201,7 +201,7 @@ subroutine surface_driver(localpet) call calc_liq_soil_moisture !--------------------------------------------------------------------------------------------- -! Set z0 at land and sea ice. +! Set z0 at water and sea ice. !--------------------------------------------------------------------------------------------- call roughness @@ -2623,7 +2623,7 @@ subroutine qc_check enddo enddo - print*,"- SET NON-ICE FLAG FOR TARGET GRID ICE TEMPERATURE." + print*,"- SET NON-ICE FLAG FOR TARGET GRID ICE COLUMN TEMPERATURE." call ESMF_FieldGet(ice_temp_target_grid, & farrayPtr=ice_ptr, rc=rc) if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__)) & From a82eaf236332014806e8f16c40ac248fbacd88de Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 5 Jan 2024 17:52:47 +0000 Subject: [PATCH 090/107] Update the c96.fv3.restart regression test to use the latest fractional orog and grid files. Fixes #123 --- reg_tests/chgres_cube/c96.fv3.restart.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reg_tests/chgres_cube/c96.fv3.restart.sh b/reg_tests/chgres_cube/c96.fv3.restart.sh index 21e9553a7..3c3cf9777 100755 --- a/reg_tests/chgres_cube/c96.fv3.restart.sh +++ b/reg_tests/chgres_cube/c96.fv3.restart.sh @@ -12,8 +12,9 @@ set -x export DATA=$OUTDIR/c96_fv3_restart rm -fr $DATA -export FIXfv3=${HOMEreg}/fix/C96 -export FIXsfc=${FIXfv3}/fix_sfc +export CRES=96 +export ocn=100 +export FIXfv3=${HOMEreg}/fix/C${CRES} export COMIN=${HOMEreg}/input_data/fv3.restart export VCOORD_FILE=${HOMEufs}/fix/am/global_hyblev.l64.txt export INPUT_TYPE='restart' From ff2e2ca10442d54aa65f49d3cc4627bfd25bcac2 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 5 Jan 2024 19:43:29 +0000 Subject: [PATCH 091/107] Update the remaining global C96 regression tests to use the fractional orog and grid files. Fixes #123. --- reg_tests/chgres_cube/c96.fv3.nemsio.sh | 6 ++++-- reg_tests/chgres_cube/c96.fv3.netcdf.sh | 6 ++++-- reg_tests/chgres_cube/c96.fv3.netcdf2wam.sh | 5 ++++- reg_tests/chgres_cube/c96.gefs.grib2.sh | 5 +++-- reg_tests/chgres_cube/c96.gfs.nemsio.sh | 6 ++++-- reg_tests/chgres_cube/c96.gfs.sigio.sh | 6 ++++-- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/reg_tests/chgres_cube/c96.fv3.nemsio.sh b/reg_tests/chgres_cube/c96.fv3.nemsio.sh index e9899dfdc..1e35eb79c 100755 --- a/reg_tests/chgres_cube/c96.fv3.nemsio.sh +++ b/reg_tests/chgres_cube/c96.fv3.nemsio.sh @@ -12,8 +12,10 @@ set -x export DATA=$OUTDIR/c96_fv3_nemsio rm -fr $DATA -export FIXfv3=${HOMEreg}/fix/C96 -export FIXsfc=${FIXfv3}/fix_sfc +export CRES=96 +export ocn=100 +export FIXfv3=${HOMEreg}/fix/C${CRES} + export COMIN=${HOMEreg}/input_data/fv3.nemsio export ATM_FILES_INPUT=gfs.t12z.atmf000.nemsio export SFC_FILES_INPUT=gfs.t12z.sfcf000.nemsio diff --git a/reg_tests/chgres_cube/c96.fv3.netcdf.sh b/reg_tests/chgres_cube/c96.fv3.netcdf.sh index 10adb17c6..df55a1f8a 100755 --- a/reg_tests/chgres_cube/c96.fv3.netcdf.sh +++ b/reg_tests/chgres_cube/c96.fv3.netcdf.sh @@ -12,8 +12,10 @@ set -x export DATA=$OUTDIR/c96_fv3_netcdf rm -fr $DATA -export FIXfv3=${HOMEreg}/fix/C96 -export FIXsfc=${FIXfv3}/fix_sfc +export CRES=96 +export ocn=100 +export FIXfv3=${HOMEreg}/fix/C${CRES} + export COMIN=${HOMEreg}/input_data/fv3.netcdf export ATM_FILES_INPUT=gfs.t00z.atmf000.nc export SFC_FILES_INPUT=gfs.t00z.sfcf000.nc diff --git a/reg_tests/chgres_cube/c96.fv3.netcdf2wam.sh b/reg_tests/chgres_cube/c96.fv3.netcdf2wam.sh index 269448759..efdea6627 100755 --- a/reg_tests/chgres_cube/c96.fv3.netcdf2wam.sh +++ b/reg_tests/chgres_cube/c96.fv3.netcdf2wam.sh @@ -12,7 +12,10 @@ set -x export DATA=$OUTDIR/c96_fv3_netcdf2wam rm -fr $DATA -export FIXfv3=${HOMEreg}/fix/C96 +export CRES=96 +export ocn=100 +export FIXfv3=${HOMEreg}/fix/C${CRES} + export COMIN=${HOMEreg}/input_data/fv3.netcdf export ATM_FILES_INPUT=gfs.t00z.atmf000.nc export VCOORD_FILE=${HOMEufs}/fix/am/global_hyblev.l64.txt diff --git a/reg_tests/chgres_cube/c96.gefs.grib2.sh b/reg_tests/chgres_cube/c96.gefs.grib2.sh index 937b42395..a4dabc3cd 100755 --- a/reg_tests/chgres_cube/c96.gefs.grib2.sh +++ b/reg_tests/chgres_cube/c96.gefs.grib2.sh @@ -13,8 +13,9 @@ export DATA=$OUTDIR/c96_gefs_grib2 rm -fr $DATA export CRES=96 -export FIXfv3=${HOMEreg}/fix/C96 -export FIXsfc=${FIXfv3}/fix_sfc +export ocn=100 +export FIXfv3=${HOMEreg}/fix/C${CRES} + export COMIN=${HOMEreg}/input_data/gefs.grib2 export GRIB2_FILE_INPUT=gec00.t06z.pgrb2abf00 diff --git a/reg_tests/chgres_cube/c96.gfs.nemsio.sh b/reg_tests/chgres_cube/c96.gfs.nemsio.sh index 7b36c23e1..2eb8cb297 100755 --- a/reg_tests/chgres_cube/c96.gfs.nemsio.sh +++ b/reg_tests/chgres_cube/c96.gfs.nemsio.sh @@ -12,8 +12,10 @@ set -x export DATA=$OUTDIR/c96_gfs_nemsio rm -fr $DATA -export FIXfv3=${HOMEreg}/fix/C96 -export FIXsfc=${FIXfv3}/fix_sfc +export CRES=96 +export ocn=100 +export FIXfv3=${HOMEreg}/fix/C${CRES} + export COMIN=${HOMEreg}/input_data/gfs.nemsio export ATM_FILES_INPUT=gfnanl.gdas.2017071700 export SFC_FILES_INPUT=sfnanl.gdas.2017071700 diff --git a/reg_tests/chgres_cube/c96.gfs.sigio.sh b/reg_tests/chgres_cube/c96.gfs.sigio.sh index 99b7909e9..c4a45fcc6 100755 --- a/reg_tests/chgres_cube/c96.gfs.sigio.sh +++ b/reg_tests/chgres_cube/c96.gfs.sigio.sh @@ -18,8 +18,10 @@ fi export DATA=$OUTDIR/c96_gfs_sigio rm -fr $DATA -export FIXfv3=${HOMEreg}/fix/C96 -export FIXsfc=${FIXfv3}/fix_sfc +export CRES=96 +export ocn=100 +export FIXfv3=${HOMEreg}/fix/C${CRES} + export COMIN=${HOMEreg}/input_data/gfs.sigio export ATM_FILES_INPUT=gdas.t00z.sanl export SFC_FILES_INPUT=gdas.t00z.sfcanl From a0ce2a3df834046f610e6824dd2709f48a884d04 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 5 Jan 2024 20:06:29 +0000 Subject: [PATCH 092/107] Delete the c96 regional test as there are already multiple regional test cases. Fixes #123. --- reg_tests/chgres_cube/c96.regional.sh | 83 --------------------------- reg_tests/chgres_cube/driver.hera.sh | 55 ++++++++---------- 2 files changed, 23 insertions(+), 115 deletions(-) delete mode 100755 reg_tests/chgres_cube/c96.regional.sh diff --git a/reg_tests/chgres_cube/c96.regional.sh b/reg_tests/chgres_cube/c96.regional.sh deleted file mode 100755 index 6ba6f33da..000000000 --- a/reg_tests/chgres_cube/c96.regional.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash - -#----------------------------------------------------------------------------- -# Invoke chgres to create C96 regional coldstart files, including a lateral -# boundary file, using FV3 gaussian nemsio files as input. The -# coldstart files are then compared to baseline files using the 'nccmp' -# utility. -# -# This script is run by the machine specific driver script. -#----------------------------------------------------------------------------- - -set -x - -export DATA=$OUTDIR/c96_regional -rm -fr $DATA - -export FIXfv3=${HOMEreg}/fix/C96.regional -export FIXsfc=${FIXfv3}/fix_sfc -export OROG_FILES_TARGET_GRID="C96_oro_data.tile7.nc" -export COMIN=${HOMEreg}/input_data/fv3.nemsio -export ATM_FILES_INPUT=gfs.t12z.atmf000.nemsio -export SFC_FILES_INPUT=gfs.t12z.sfcf000.nemsio -export VCOORD_FILE=${HOMEufs}/fix/am/global_hyblev.l64.txt -export REGIONAL=1 -export HALO_BLEND=0 -export HALO_BNDY=4 - -export CDATE=2019070412 - -export OMP_NUM_THREADS_CH=${OMP_NUM_THREADS:-1} - -NCCMP=${NCCMP:-$(which nccmp)} - -#----------------------------------------------------------------------------- -# Invoke chgres program. -#----------------------------------------------------------------------------- - -echo "Starting at: " `date` - -${HOMEufs}/ush/chgres_cube.sh - -iret=$? -if [ $iret -ne 0 ]; then - set +x - echo "<<< C96 REGIONAL TEST FAILED. <<<" - exit $iret -fi - -echo "Ending at: " `date` - -#----------------------------------------------------------------------------- -# Compare output from chgres to baseline set of data. -#----------------------------------------------------------------------------- - -cd $DATA - -mv out.sfc.tile7.nc out.sfc.tile1.nc -mv out.atm.tile7.nc out.atm.tile1.nc - -test_failed=0 -for files in *.nc -do - if [ -f $files ]; then - echo CHECK $files - $NCCMP -dmfqS $files $HOMEreg/baseline_data/c96_regional/$files - iret=$? - if [ $iret -ne 0 ]; then - test_failed=1 - fi - fi -done - -set +x -if [ $test_failed -ne 0 ]; then - echo "<<< C96 REGIONAL TEST FAILED. >>>" - if [ "$UPDATE_BASELINE" = "TRUE" ]; then - $HOMEufs/reg_tests/update_baseline.sh $HOMEreg "c96_regional" $commit_num - fi -else - echo "<<< C96 REGIONAL TEST PASSED. >>>" -fi - -exit 0 diff --git a/reg_tests/chgres_cube/driver.hera.sh b/reg_tests/chgres_cube/driver.hera.sh index d7a42a80a..3f14d9b08 100755 --- a/reg_tests/chgres_cube/driver.hera.sh +++ b/reg_tests/chgres_cube/driver.hera.sh @@ -110,112 +110,103 @@ export OMP_NUM_THREADS=1 # should match cpus-per-task TEST5=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:15:00 -A $PROJECT_CODE -q $QUEUE -J c96.gfs.nemsio \ -o $LOG_FILE -e $LOG_FILE ./c96.gfs.nemsio.sh) -#----------------------------------------------------------------------------- -# Initialize regional C96 using FV3 gaussian nemsio files. -#----------------------------------------------------------------------------- - -LOG_FILE=consistency.log06 -export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST6=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:15:00 -A $PROJECT_CODE -q $QUEUE -J c96.regional \ - -o $LOG_FILE -e $LOG_FILE ./c96.regional.sh) - #----------------------------------------------------------------------------- # Initialize C96 using FV3 gaussian netcdf files. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log07 +LOG_FILE=consistency.log06 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST7=$(sbatch --parsable --ntasks-per-node=12 --nodes=1 -t 0:15:00 -A $PROJECT_CODE -q $QUEUE -J c96.fv3.netcdf \ +TEST6=$(sbatch --parsable --ntasks-per-node=12 --nodes=1 -t 0:15:00 -A $PROJECT_CODE -q $QUEUE -J c96.fv3.netcdf \ -o $LOG_FILE -e $LOG_FILE ./c96.fv3.netcdf.sh) #----------------------------------------------------------------------------- # Initialize global C192 using GFS GRIB2 files. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log08 +LOG_FILE=consistency.log07 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST8=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c192.gfs.grib2 \ +TEST7=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c192.gfs.grib2 \ -o $LOG_FILE -e $LOG_FILE ./c192.gfs.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 25-KM USING GFS GRIB2 files. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log09 +LOG_FILE=consistency.log08 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST9=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.grib2.conus \ +TEST8=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.grib2.conus \ -o $LOG_FILE -e $LOG_FILE ./25km.conus.gfs.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 3-KM USING HRRR GRIB2 file WITH GFS PHYSICS. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log10 +LOG_FILE=consistency.log09 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST10=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 3km.conus.hrrr.gfssdf.grib2.conus \ +TEST09=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 3km.conus.hrrr.gfssdf.grib2.conus \ -o $LOG_FILE -e $LOG_FILE ./3km.conus.hrrr.gfssdf.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 3-KM USING HRRR GRIB2 file WITH GSD PHYSICS AND SFC VARS FROM FILE. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log11 +LOG_FILE=consistency.log10 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST11=$(sbatch --parsable --ntasks-per-node=6 --nodes=2 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 3km.conus.hrrr.newsfc.grib2.conus \ +TEST10=$(sbatch --parsable --ntasks-per-node=6 --nodes=2 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 3km.conus.hrrr.newsfc.grib2.conus \ -o $LOG_FILE -e $LOG_FILE ./3km.conus.hrrr.newsfc.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 13-KM USING NAM GRIB2 file WITH GFS PHYSICS . #----------------------------------------------------------------------------- -LOG_FILE=consistency.log12 +LOG_FILE=consistency.log11 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST12=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 13km.conus.nam.grib2.conus \ +TEST11=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 13km.conus.nam.grib2.conus \ -o $LOG_FILE -e $LOG_FILE ./13km.conus.nam.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 13-KM USING RAP GRIB2 file WITH GSD PHYSICS . #----------------------------------------------------------------------------- -LOG_FILE=consistency.log13 +LOG_FILE=consistency.log12 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST13=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 13km.conus.rap.grib2.conus \ +TEST12=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 13km.conus.rap.grib2.conus \ -o $LOG_FILE -e $LOG_FILE ./13km.conus.rap.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 13-KM NA USING NCEI GFS GRIB2 file WITH GFS PHYSICS . #----------------------------------------------------------------------------- -LOG_FILE=consistency.log14 +LOG_FILE=consistency.log13 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST14=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 13km.na.gfs.ncei.grib2.conus \ +TEST13=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 13km.na.gfs.ncei.grib2.conus \ -o $LOG_FILE -e $LOG_FILE ./13km.na.gfs.ncei.grib2.sh) #----------------------------------------------------------------------------- # Initialize C96 WAM IC using FV3 gaussian netcdf files. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log15 +LOG_FILE=consistency.log14 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST15=$(sbatch --parsable --ntasks-per-node=12 --nodes=1 -t 0:15:00 -A $PROJECT_CODE -q $QUEUE -J c96.fv3.netcdf2wam \ +TEST14=$(sbatch --parsable --ntasks-per-node=12 --nodes=1 -t 0:15:00 -A $PROJECT_CODE -q $QUEUE -J c96.fv3.netcdf2wam \ -o $LOG_FILE -e $LOG_FILE ./c96.fv3.netcdf2wam.sh) #----------------------------------------------------------------------------- # Initialize CONUS 25-KM USING GFS PGRIB2+BGRIB2 files. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log16 +LOG_FILE=consistency.log15 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST16=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.pbgrib2.conus \ +TEST15=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.pbgrib2.conus \ -o $LOG_FILE -e $LOG_FILE ./25km.conus.gfs.pbgrib2.sh) #----------------------------------------------------------------------------- # Initialize global C96 using GEFS GRIB2 files. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log17 +LOG_FILE=consistency.log16 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST17=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c96.gefs.grib2 \ +TEST16=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c96.gefs.grib2 \ -o $LOG_FILE -e $LOG_FILE ./c96.gefs.grib2.sh) #----------------------------------------------------------------------------- @@ -224,7 +215,7 @@ TEST17=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_ LOG_FILE=consistency.log sbatch --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J chgres_summary -o $LOG_FILE -e $LOG_FILE \ --open-mode=append -q $QUEUE -d\ - afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16:$TEST17 << EOF + afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16 << EOF #!/bin/bash grep -a '<<<' $LOG_FILE* > $SUM_FILE EOF From 4195825ccac8a8675ba1cb4469ba728f311929de Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 5 Jan 2024 21:20:19 +0000 Subject: [PATCH 093/107] Update the c192.gfs.grib2 test to use the latest fractional 'oro' and 'grid' files. Fixes #123. --- reg_tests/chgres_cube/c192.gfs.grib2.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reg_tests/chgres_cube/c192.gfs.grib2.sh b/reg_tests/chgres_cube/c192.gfs.grib2.sh index 95762ac9b..e45b74d53 100755 --- a/reg_tests/chgres_cube/c192.gfs.grib2.sh +++ b/reg_tests/chgres_cube/c192.gfs.grib2.sh @@ -13,8 +13,9 @@ export DATA=$OUTDIR/c192_gfs_grib2 rm -fr $DATA export CRES=192 -export FIXfv3=${HOMEreg}/fix/C192 -export FIXsfc=${FIXfv3}/fix_sfc +export ocn=100 +export FIXfv3=${HOMEreg}/fix/C${CRES} + export COMIN=${HOMEreg}/input_data/gfs.grib2 export GRIB2_FILE_INPUT=gfs.t00z.pgrb2.0p50.f000 From 4284a6657c70b2d0d3f3128012ee1388cb91fae6 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 5 Jan 2024 22:01:07 +0000 Subject: [PATCH 094/107] Update c192.fv3.history test for the new fractional 'oro' and 'grid' files. Fixes #123. --- reg_tests/chgres_cube/c192.fv3.history.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/reg_tests/chgres_cube/c192.fv3.history.sh b/reg_tests/chgres_cube/c192.fv3.history.sh index 34d23c3e6..c46739691 100755 --- a/reg_tests/chgres_cube/c192.fv3.history.sh +++ b/reg_tests/chgres_cube/c192.fv3.history.sh @@ -13,8 +13,9 @@ export DATA=$OUTDIR/c192_fv3_history rm -fr $DATA export CRES=192 -export FIXfv3=${HOMEreg}/fix/C192 -export FIXsfc=${FIXfv3}/fix_sfc +export ocn=100 +export FIXfv3=${HOMEreg}/fix/C${CRES} + export COMIN=${HOMEreg}/input_data/fv3.history # Pay attention to the quotes. Dont start/end with double quote. @@ -22,8 +23,8 @@ export ATM_FILES_INPUT='dynf000.tile1.nc","dynf000.tile2.nc","dynf000.tile3.nc", export SFC_FILES_INPUT='phyf000.tile1.nc","phyf000.tile2.nc","phyf000.tile3.nc","phyf000.tile4.nc","phyf000.tile5.nc","phyf000.tile6.nc' export VCOORD_FILE=${HOMEufs}/fix/am/global_hyblev.l64.txt export INPUT_TYPE='history' -export MOSAIC_FILE_INPUT_GRID="${HOMEreg}/fix/C96/C96_mosaic.nc" -export OROG_DIR_INPUT_GRID=${HOMEreg}/fix/C96 +export MOSAIC_FILE_INPUT_GRID="${HOMEreg}/fix/C96.history.file/C96_mosaic.nc" +export OROG_DIR_INPUT_GRID=${HOMEreg}/fix/C96.history.file export OROG_FILES_INPUT_GRID='C96_oro_data.tile1.nc","C96_oro_data.tile2.nc","C96_oro_data.tile3.nc","C96_oro_data.tile4.nc","C96_oro_data.tile5.nc","C96_oro_data.tile6.nc' export TRACERS_TARGET='"sphum","liq_wat","o3mr"' export TRACERS_INPUT='"spfh","clwmr","o3mr"' From d28519a64b3e2d9f0148cf6da8c1acb532f1be23 Mon Sep 17 00:00:00 2001 From: "George.Gayno" Date: Tue, 9 Jan 2024 18:29:51 +0000 Subject: [PATCH 095/107] Force sfc_climo_gen to always place a valid value at all points with at least some land. Fixes #123. --- sorc/sfc_climo_gen.fd/model_grid.F90 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sorc/sfc_climo_gen.fd/model_grid.F90 b/sorc/sfc_climo_gen.fd/model_grid.F90 index abc6b4b37..b2c8f8fc4 100644 --- a/sorc/sfc_climo_gen.fd/model_grid.F90 +++ b/sorc/sfc_climo_gen.fd/model_grid.F90 @@ -370,16 +370,16 @@ subroutine get_model_info(orog_file, mask, land_frac, lat2d, lon2d, idim, jdim) ! surface data will not be mapped to it. !----------------------------------------------------------------------- - error=nf90_inq_varid(ncid, 'lake_frac', id_var) - if (error /= 0) then - print*,"- READ LAND MASK (SLMSK)" - error=nf90_inq_varid(ncid, 'slmsk', id_var) - call netcdf_err(error, "READING SLMSK ID") - error=nf90_get_var(ncid, id_var, dummy) - call netcdf_err(error, "READING SLMSK") - mask = nint(dummy) - land_frac = -999. - else +!error=nf90_inq_varid(ncid, 'lake_frac', id_var) +!if (error /= 0) then +! print*,"- READ LAND MASK (SLMSK)" +! error=nf90_inq_varid(ncid, 'slmsk', id_var) +! call netcdf_err(error, "READING SLMSK ID") +! error=nf90_get_var(ncid, id_var, dummy) +! call netcdf_err(error, "READING SLMSK") +! mask = nint(dummy) +! land_frac = -999. +!else print*,"- READ LAND FRACTION" error=nf90_inq_varid(ncid, 'land_frac', id_var) call netcdf_err(error, "READING LAND_FRAC ID") @@ -393,7 +393,7 @@ subroutine get_model_info(orog_file, mask, land_frac, lat2d, lon2d, idim, jdim) endif enddo enddo - endif +!endif print*,"- READ LATITUDE" error=nf90_inq_varid(ncid, 'geolat', id_var) From b7317bc9509a7d033caffd9c2783f29cf5a30672 Mon Sep 17 00:00:00 2001 From: "George.Gayno" Date: Tue, 9 Jan 2024 19:14:27 +0000 Subject: [PATCH 096/107] Fix bug in creation of grid readme file. Fixes #123. --- ush/fv3gfs_driver_grid.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ush/fv3gfs_driver_grid.sh b/ush/fv3gfs_driver_grid.sh index aafa48cae..710e9fbfb 100755 --- a/ush/fv3gfs_driver_grid.sh +++ b/ush/fv3gfs_driver_grid.sh @@ -636,7 +636,7 @@ The following parameters were used soil_type=$soil_type_src lake_data_srce=$lake_data_srce target_lon=$target_lon # Center longitude of grid - target_lat=target_lat # Center latitude of grid + target_lat=$target_lat # Center latitude of grid idim=$idim # Dimension of grid in 'i' direction jdim=$jdim # Dimension of grid in 'j' direction delx=$delx # Grid spacing (in degrees) in the 'i' direction From 28ae54bad1ee538436aa7d4536e240b9134b365e Mon Sep 17 00:00:00 2001 From: "George.Gayno" Date: Tue, 9 Jan 2024 20:35:25 +0000 Subject: [PATCH 097/107] Update the 25km tests to use new fixed data with sfc climo data at all points with some land. Fixes #123. --- reg_tests/chgres_cube/25km.conus.gfs.grib2.sh | 8 ++++---- reg_tests/chgres_cube/25km.conus.gfs.pbgrib2.sh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/reg_tests/chgres_cube/25km.conus.gfs.grib2.sh b/reg_tests/chgres_cube/25km.conus.gfs.grib2.sh index b7cb4129d..5d5403c1d 100755 --- a/reg_tests/chgres_cube/25km.conus.gfs.grib2.sh +++ b/reg_tests/chgres_cube/25km.conus.gfs.grib2.sh @@ -12,10 +12,10 @@ set -x export DATA=$OUTDIR/25km_conus_gfs_grib2 rm -fr $DATA -export CRES=403 +export CRES=405 export KMRES=25km -export FIXfv3=${HOMEreg}/fix/RRFS_CONUS_${KMRES} -export FIXsfc=${FIXfv3}/fix_sfc +export FIXfv3=${HOMEreg}/fix.new/RRFS_CONUS_${KMRES} + export COMIN=${HOMEreg}/input_data/gfs.grib2 export GRIB2_FILE_INPUT=gfs.t00z.pgrb2.0p50.f000 @@ -24,7 +24,7 @@ export VARMAP_FILE=${HOMEufs}/parm/varmap_tables/GSDphys_noaero_var_map.txt export INPUT_TYPE='grib2' export CONVERT_NST=".false." export THOMPSON_AEROSOL_FILE=${HOMEufs}/fix/am/Thompson_MP_MONTHLY_CLIMO.nc -export OROG_FILES_TARGET_GRID="C403_oro_data.tile7.halo4.nc" +export OROG_FILES_TARGET_GRID="C405_oro_data.tile7.nc" export REGIONAL=1 export HALO_BLEND=0 export HALO_BNDY=4 diff --git a/reg_tests/chgres_cube/25km.conus.gfs.pbgrib2.sh b/reg_tests/chgres_cube/25km.conus.gfs.pbgrib2.sh index b104804a8..40e9c6f17 100755 --- a/reg_tests/chgres_cube/25km.conus.gfs.pbgrib2.sh +++ b/reg_tests/chgres_cube/25km.conus.gfs.pbgrib2.sh @@ -12,10 +12,10 @@ set -x export DATA=$OUTDIR/25km_conus_gfs_pbgrib2 rm -fr $DATA -export CRES=403 +export CRES=405 export KMRES=25km -export FIXfv3=${HOMEreg}/fix/RRFS_CONUS_${KMRES} -export FIXsfc=${FIXfv3}/fix_sfc +export FIXfv3=${HOMEreg}/fix.new/RRFS_CONUS_${KMRES} + export COMIN=${HOMEreg}/input_data/gfs.pbgrib2 export GRIB2_FILE_INPUT=gfs.t18z.pgrb2.0p25.f006 @@ -23,7 +23,7 @@ export VCOORD_FILE=${HOMEufs}/fix/am/global_hyblev.l64.txt export VARMAP_FILE=${HOMEufs}/parm/varmap_tables/GFSphys_var_map.txt export INPUT_TYPE='grib2' export CONVERT_NST=".false." -export OROG_FILES_TARGET_GRID="C403_oro_data.tile7.halo4.nc" +export OROG_FILES_TARGET_GRID="C405_oro_data.tile7.nc" export REGIONAL=1 export HALO_BLEND=0 export HALO_BNDY=4 From b074fd5a256685eda0e414d9fe82dc24e277d11a Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 10 Jan 2024 13:59:21 +0000 Subject: [PATCH 098/107] Updates for the 13km and 25 km CONUS tests. Fixes #123. --- reg_tests/chgres_cube/13km.conus.nam.grib2.sh | 6 +++--- reg_tests/chgres_cube/13km.conus.rap.grib2.sh | 6 +++--- reg_tests/chgres_cube/25km.conus.gfs.grib2.sh | 2 +- reg_tests/chgres_cube/25km.conus.gfs.pbgrib2.sh | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/reg_tests/chgres_cube/13km.conus.nam.grib2.sh b/reg_tests/chgres_cube/13km.conus.nam.grib2.sh index 16af5e42b..a5bd051c4 100755 --- a/reg_tests/chgres_cube/13km.conus.nam.grib2.sh +++ b/reg_tests/chgres_cube/13km.conus.nam.grib2.sh @@ -12,10 +12,10 @@ set -x export DATA=$OUTDIR/13km_conus_nam_grib2 rm -fr $DATA -export CRES=775 +export CRES=778 export KMRES=13km export FIXfv3=${HOMEreg}/fix/RRFS_CONUS_${KMRES} -export FIXsfc=${FIXfv3}/fix_sfc + export COMIN=${HOMEreg}/input_data/nam.grib2 export GRIB2_FILE_INPUT=nam_218_20200801_0000_000.grb2 @@ -23,7 +23,7 @@ export VCOORD_FILE=${HOMEufs}/fix/am/global_hyblev.l64.txt export VARMAP_FILE=${HOMEufs}/parm/varmap_tables/GFSphys_var_map.txt export INPUT_TYPE='grib2' export CONVERT_NST=".false." -export OROG_FILES_TARGET_GRID="C775_oro_data.tile7.halo4.nc" +export OROG_FILES_TARGET_GRID="C778_oro_data.tile7.nc" export REGIONAL=1 export HALO_BLEND=0 export HALO_BNDY=4 diff --git a/reg_tests/chgres_cube/13km.conus.rap.grib2.sh b/reg_tests/chgres_cube/13km.conus.rap.grib2.sh index e69bff8b0..4b684b646 100755 --- a/reg_tests/chgres_cube/13km.conus.rap.grib2.sh +++ b/reg_tests/chgres_cube/13km.conus.rap.grib2.sh @@ -12,10 +12,10 @@ set -x export DATA=$OUTDIR/13km_conus_rap_grib2 rm -fr $DATA -export CRES=775 +export CRES=778 export KMRES=13km export FIXfv3=${HOMEreg}/fix/RRFS_CONUS_${KMRES} -export FIXsfc=${FIXfv3}/fix_sfc + export COMIN=${HOMEreg}/input_data/rap.grib2 export GRIB2_FILE_INPUT=1921221000900 @@ -23,7 +23,7 @@ export VCOORD_FILE=${HOMEufs}/fix/am/global_hyblev.l64.txt export VARMAP_FILE=${HOMEufs}/parm/varmap_tables/GSDphys_var_map.txt export INPUT_TYPE='grib2' export CONVERT_NST=".false." -export OROG_FILES_TARGET_GRID="C775_oro_data.tile7.nc" +export OROG_FILES_TARGET_GRID="C778_oro_data.tile7.nc" export REGIONAL=1 export HALO_BLEND=0 export HALO_BNDY=4 diff --git a/reg_tests/chgres_cube/25km.conus.gfs.grib2.sh b/reg_tests/chgres_cube/25km.conus.gfs.grib2.sh index 5d5403c1d..2efb252d7 100755 --- a/reg_tests/chgres_cube/25km.conus.gfs.grib2.sh +++ b/reg_tests/chgres_cube/25km.conus.gfs.grib2.sh @@ -14,7 +14,7 @@ rm -fr $DATA export CRES=405 export KMRES=25km -export FIXfv3=${HOMEreg}/fix.new/RRFS_CONUS_${KMRES} +export FIXfv3=${HOMEreg}/fix/RRFS_CONUS_${KMRES} export COMIN=${HOMEreg}/input_data/gfs.grib2 diff --git a/reg_tests/chgres_cube/25km.conus.gfs.pbgrib2.sh b/reg_tests/chgres_cube/25km.conus.gfs.pbgrib2.sh index 40e9c6f17..4b3491516 100755 --- a/reg_tests/chgres_cube/25km.conus.gfs.pbgrib2.sh +++ b/reg_tests/chgres_cube/25km.conus.gfs.pbgrib2.sh @@ -14,7 +14,7 @@ rm -fr $DATA export CRES=405 export KMRES=25km -export FIXfv3=${HOMEreg}/fix.new/RRFS_CONUS_${KMRES} +export FIXfv3=${HOMEreg}/fix/RRFS_CONUS_${KMRES} export COMIN=${HOMEreg}/input_data/gfs.pbgrib2 From 51590206c3d85b2e0e6f8de9aab265a439742e63 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Wed, 10 Jan 2024 15:35:52 +0000 Subject: [PATCH 099/107] Update 13 km NA test to use new fixed files. Fixes #123. --- reg_tests/chgres_cube/13km.na.gfs.ncei.grib2.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/reg_tests/chgres_cube/13km.na.gfs.ncei.grib2.sh b/reg_tests/chgres_cube/13km.na.gfs.ncei.grib2.sh index 2e48b8095..c3e0c6f5d 100755 --- a/reg_tests/chgres_cube/13km.na.gfs.ncei.grib2.sh +++ b/reg_tests/chgres_cube/13km.na.gfs.ncei.grib2.sh @@ -12,10 +12,9 @@ set -x export DATA=$OUTDIR/13km_na_gfs_ncei_grib2 rm -fr $DATA -export CRES=819 +export CRES=818 export KMRES=13km export FIXfv3=${HOMEreg}/fix/RRFS_NA_${KMRES} -export FIXsfc=${FIXfv3}/fix_sfc export COMIN=${HOMEreg}/input_data/gfs.ncei.grib2 export GRIB2_FILE_INPUT=gfs_4_20190801_0000_000.grb2 @@ -23,7 +22,7 @@ export VCOORD_FILE=${HOMEufs}/fix/am/global_hyblev.l64.txt export VARMAP_FILE=${HOMEufs}/parm/varmap_tables/GFSphys_var_map.txt export INPUT_TYPE='grib2' export CONVERT_NST=".false." -export OROG_FILES_TARGET_GRID="C819_oro_data.tile7.halo4.nc" +export OROG_FILES_TARGET_GRID="C818_oro_data.tile7.nc" export REGIONAL=1 export HALO_BLEND=0 export HALO_BNDY=4 From 548a01a96870a8b25ce99e0c5d38cbcc151b4e20 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 11 Jan 2024 14:57:57 +0000 Subject: [PATCH 100/107] Update 3km tests for new surface fixed data. Fixes #123. --- reg_tests/chgres_cube/3km.conus.hrrr.gfssdf.grib2.sh | 2 +- reg_tests/chgres_cube/3km.conus.hrrr.newsfc.grib2.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/reg_tests/chgres_cube/3km.conus.hrrr.gfssdf.grib2.sh b/reg_tests/chgres_cube/3km.conus.hrrr.gfssdf.grib2.sh index 63e7702c5..4f72173d6 100755 --- a/reg_tests/chgres_cube/3km.conus.hrrr.gfssdf.grib2.sh +++ b/reg_tests/chgres_cube/3km.conus.hrrr.gfssdf.grib2.sh @@ -15,7 +15,7 @@ rm -fr $DATA export CRES=3357 export KMRES=3km export FIXfv3=${HOMEreg}/fix/RRFS_CONUS_${KMRES} -export FIXsfc=${FIXfv3}/fix_sfc + export COMIN=${HOMEreg}/input_data/hrrr.grib2 export GRIB2_FILE_INPUT=1918200000000 diff --git a/reg_tests/chgres_cube/3km.conus.hrrr.newsfc.grib2.sh b/reg_tests/chgres_cube/3km.conus.hrrr.newsfc.grib2.sh index a8dfcea9e..86a3d8939 100755 --- a/reg_tests/chgres_cube/3km.conus.hrrr.newsfc.grib2.sh +++ b/reg_tests/chgres_cube/3km.conus.hrrr.newsfc.grib2.sh @@ -15,7 +15,7 @@ rm -fr $DATA export CRES=3357 export KMRES=3km export FIXfv3=${HOMEreg}/fix/RRFS_CONUS_${KMRES} -export FIXsfc=${FIXfv3}/fix_sfc + export COMIN=${HOMEreg}/input_data/hrrr.grib2 export GRIB2_FILE_INPUT=1921300000000 From a6972bc4337ed24082e4af71c0a12eef9b2294d0 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 11 Jan 2024 15:49:41 +0000 Subject: [PATCH 101/107] Minor bug fix in Hera regression test driver. Fixes #123. --- reg_tests/chgres_cube/driver.hera.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reg_tests/chgres_cube/driver.hera.sh b/reg_tests/chgres_cube/driver.hera.sh index 3f14d9b08..21025637c 100755 --- a/reg_tests/chgres_cube/driver.hera.sh +++ b/reg_tests/chgres_cube/driver.hera.sh @@ -143,7 +143,7 @@ TEST8=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_C LOG_FILE=consistency.log09 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST09=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 3km.conus.hrrr.gfssdf.grib2.conus \ +TEST9=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 3km.conus.hrrr.gfssdf.grib2.conus \ -o $LOG_FILE -e $LOG_FILE ./3km.conus.hrrr.gfssdf.grib2.sh) #----------------------------------------------------------------------------- From d11ef7218e0fb91b9fdb14e6e28f3254591bf7bb Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 11 Jan 2024 17:17:48 +0000 Subject: [PATCH 102/107] Remove the two temporary chgres utility programs. Fixes #123. --- sorc/CMakeLists.txt | 2 - sorc/chgres_tools.fd/CMakeLists.txt | 16 -- sorc/chgres_tools.fd/check.F90 | 239 --------------------- sorc/chgres_tools2.fd/CMakeLists.txt | 16 -- sorc/chgres_tools2.fd/check.F90 | 300 --------------------------- 5 files changed, 573 deletions(-) delete mode 100644 sorc/chgres_tools.fd/CMakeLists.txt delete mode 100644 sorc/chgres_tools.fd/check.F90 delete mode 100644 sorc/chgres_tools2.fd/CMakeLists.txt delete mode 100644 sorc/chgres_tools2.fd/check.F90 diff --git a/sorc/CMakeLists.txt b/sorc/CMakeLists.txt index d61ed7cf8..b08bd79bd 100644 --- a/sorc/CMakeLists.txt +++ b/sorc/CMakeLists.txt @@ -24,8 +24,6 @@ if(GRIDTOOLS) endif() if(CHGRES) add_subdirectory(chgres_cube.fd) - add_subdirectory(chgres_tools.fd) - add_subdirectory(chgres_tools2.fd) endif() if(OROG_MASK_TOOLS) add_subdirectory(orog_mask_tools.fd) diff --git a/sorc/chgres_tools.fd/CMakeLists.txt b/sorc/chgres_tools.fd/CMakeLists.txt deleted file mode 100644 index 367075dd7..000000000 --- a/sorc/chgres_tools.fd/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -set(fortran_src - check.F90) - -if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8") -elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8") -endif() - -set(exe_name chgres_check) -add_executable(${exe_name} ${fortran_src}) -target_link_libraries( - ${exe_name} - NetCDF::NetCDF_Fortran) - -install(TARGETS ${exe_name} RUNTIME DESTINATION ${exec_dir}) diff --git a/sorc/chgres_tools.fd/check.F90 b/sorc/chgres_tools.fd/check.F90 deleted file mode 100644 index 83dd5e77c..000000000 --- a/sorc/chgres_tools.fd/check.F90 +++ /dev/null @@ -1,239 +0,0 @@ - program check - -! How to use. -! -! 1) Run chgres in fractional grid mode. -! -! 2) Run chgres again using the updated orography files where 'slmsk' is -! updated to be 'ceiling(land fraction)'. Here chgres is run -! in non-fractional mode. -! -! 3) Compare the fields at land from (2) to the fields with at least -! some land from (1). They should match. - - use netcdf - - implicit none - - integer, parameter :: num_var=27 - integer, parameter :: num_var3d=3 - - character(len=150) :: file_ceiling, file_frac, file_orog_frac - - character(len=15) :: varname_frac(num_var), varname3d(num_var3d) - character(len=15) :: varname_ceil(num_var) - character(len=21) :: oro_files(6) - character(len=16) :: the_files(6) - - integer :: error, id_dim, idim, jdim, tiles - integer :: varid, varid_ceil, varid_frac, var - integer :: i, j, n, ncid_ceil, ncid_orog_frac, ncid_frac - - real*8, allocatable :: slmsk(:,:), land_frac(:,:), dummy_frac(:,:) - real*8, allocatable :: dummy_ceil(:,:) - real*8, allocatable :: dummy_frac3d(:,:,:), dummy_ceil3d(:,:,:) - - data varname_frac /'alvsf', 'alvwf', 'alnsf', 'alnwf', 'canopy', & - 'f10m' , 'facsf', 'facwf', 'ffhh' , 'ffmm', & - 'q2m' , 'shdmax','shdmin', 'sheleg', 'slope', & - 'snoalb', 'snwdph', 'srflag','stype', 't2m', & - 'tg3', 'tprcp', 'tsfcl', 'uustar', 'vfrac', & - 'vtype', 'zorll' / - - data varname_ceil /'alvsf', 'alvwf', 'alnsf', 'alnwf', 'canopy', & - 'f10m' , 'facsf', 'facwf', 'ffhh' , 'ffmm', & - 'q2m' , 'shdmax','shdmin', 'sheleg', 'slope', & - 'snoalb', 'snwdph', 'srflag','stype', 't2m', & - 'tg3', 'tprcp', 'tsea', 'uustar', 'vfrac', & - 'vtype', 'zorl' / - - data the_files /'out.sfc.tile1.nc', 'out.sfc.tile2.nc', 'out.sfc.tile3.nc', & - 'out.sfc.tile4.nc', 'out.sfc.tile5.nc', 'out.sfc.tile6.nc'/ - - data oro_files /'C96_oro_data.tile1.nc', 'C96_oro_data.tile2.nc', 'C96_oro_data.tile3.nc', & - 'C96_oro_data.tile4.nc', 'C96_oro_data.tile5.nc', 'C96_oro_data.tile6.nc' / - - data varname3d /'stc', 'slc', 'smc'/ - - TILE : do tiles = 1, 6 - - file_frac="/scratch2/NCEPDEV/stmp1/George.Gayno/chgres_fractional/" // the_files(tiles) - file_orog_frac="/scratch1/NCEPDEV/da/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & - // oro_files(tiles) - file_ceiling="/scratch2/NCEPDEV/stmp1/George.Gayno/chgres_ceiling/" // the_files(tiles) - -!file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) -!file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & -! // oro_files(tiles) -!file_ceiling="/gpfs/dell1/stmp/George.Gayno/chgres_ceiling/" // the_files(tiles) - -! Open the file created using the non-fractional logic, but with -! slmsk modified to be ceiling of the land fraction. - - print*,"- OPEN FILE ", trim(file_ceiling) - error=nf90_open(trim(file_ceiling),nf90_nowrite,ncid_ceil) - call netcdf_err(error, 'opening file_ceiling' ) - - error=nf90_inq_dimid(ncid_ceil, 'xaxis_1', id_dim) - call netcdf_err(error, 'getting xaxis' ) - error=nf90_inquire_dimension(ncid_ceil,id_dim,len=idim) - call netcdf_err(error, 'reading xaxis' ) - - error=nf90_inq_dimid(ncid_ceil, 'yaxis_1', id_dim) - call netcdf_err(error, 'getting yaxis' ) - error=nf90_inquire_dimension(ncid_ceil,id_dim,len=jdim) - call netcdf_err(error, 'reading yaxis' ) - - if(.not.allocated(slmsk)) allocate(slmsk(idim,jdim)) - - error=nf90_inq_varid(ncid_ceil,"slmsk",varid) - call netcdf_err(error, 'reading slmsk id' ) - error=nf90_get_var(ncid_ceil,varid,slmsk) - call netcdf_err(error, 'reading slmsk' ) - - print*,'slmsk ',maxval(slmsk),minval(slmsk) - -! Open the fractional grid orography file. Read the -! land fraction. - - print*,"- OPEN FILE ", trim(file_orog_frac) - error=nf90_open(trim(file_orog_frac),nf90_nowrite,ncid_orog_frac) - call netcdf_err(error, 'opening file_orog_frac' ) - - if(.not.allocated(land_frac)) allocate(land_frac(idim,jdim)) - - error=nf90_inq_varid(ncid_orog_frac,"land_frac",varid_frac) - call netcdf_err(error, 'reading land_frac id' ) - error=nf90_get_var(ncid_orog_frac,varid_frac,land_frac) - call netcdf_err(error, 'reading land_frac' ) - - print*,'land_frac ',maxval(land_frac),minval(land_frac) - -! Are the land fraction from the fractional orography file -! and the 'ceiling' slmsk created from the non-fractional -! logic consistent with each other? - - do j = 1, jdim - do i = 1, idim - if (nint(slmsk(i,j)) == 1) then - if(ceiling(land_frac(i,j)) /= 1.0_8) then - print*,'bad mask point 1', i,j,slmsk(i,j),ceiling(land_frac(i,j)) - stop - endif - endif - if (ceiling(land_frac(i,j)) == 1.0_8) then - if (nint(slmsk(i,j)) /= 1) then - print*,'bad mask point 2', i,j,slmsk(i,j),ceiling(land_frac(i,j)) - stop - endif - endif - enddo - enddo - -! Check data. - - if(.not.allocated(dummy_frac)) allocate(dummy_frac(idim,jdim)) - if(.not.allocated(dummy_ceil)) allocate(dummy_ceil(idim,jdim)) - - print*,"- OPEN FILE ", trim(file_frac) - error=nf90_open(trim(file_frac),nf90_nowrite,ncid_frac) - call netcdf_err(error, 'opening file_frac' ) - - do var = 1, num_var - - print*,'CHECK FIELD ', trim(varname_frac(var)) - - error=nf90_inq_varid(ncid_frac, varname_frac(var), varid_frac) - call netcdf_err(error, 'reading frac id' ) - error=nf90_get_var(ncid_frac,varid_frac,dummy_frac) - call netcdf_err(error, 'reading frac field' ) - - print*,'frac field ',maxval(dummy_frac),minval(dummy_frac) - - print*,'read variable ',varname_ceil(var) - error=nf90_inq_varid(ncid_ceil, varname_ceil(var), varid_ceil) - call netcdf_err(error, 'reading ceil id' ) - error=nf90_get_var(ncid_ceil,varid_ceil,dummy_ceil) - call netcdf_err(error, 'reading ceil field' ) - - print*,'ceil field ',maxval(dummy_ceil),minval(dummy_ceil) - - do j = 1, jdim - do i = 1, idim - - if (nint(slmsk(i,j)) == 1) then - if (dummy_ceil(i,j) /= dummy_frac(i,j)) then - print*,'bad pt ',i,j,dummy_ceil(i,j),dummy_frac(i,j) - stop - endif - endif - - enddo - enddo - - enddo - - if(.not.allocated(dummy_frac3d)) allocate(dummy_frac3d(idim,jdim,4)) - if(.not.allocated(dummy_ceil3d)) allocate(dummy_ceil3d(idim,jdim,4)) - - do var = 1, num_var3d - - print*,'CHECK FIELD ', trim(varname3d(var)) - - error=nf90_inq_varid(ncid_frac, varname3d(var), varid_frac) - call netcdf_err(error, 'reading frac id' ) - error=nf90_get_var(ncid_frac,varid_frac,dummy_frac3d) - call netcdf_err(error, 'reading frac field' ) - - error=nf90_inq_varid(ncid_ceil, varname3d(var), varid_ceil) - call netcdf_err(error, 'reading ceil id' ) - error=nf90_get_var(ncid_ceil,varid_ceil,dummy_ceil3d) - call netcdf_err(error, 'reading ceil field' ) - - do n = 1, 4 - - print*,'frac field level ',n,maxval(dummy_frac3d(:,:,n)),minval(dummy_frac3d(:,:,n)) - print*,'ceil field level ',n,maxval(dummy_ceil3d(:,:,n)),minval(dummy_ceil3d(:,:,n)) - - do j = 1, jdim - do i = 1, idim - - if (nint(slmsk(i,j)) == 1) then - if (dummy_ceil3d(i,j,n) /= dummy_frac3d(i,j,n)) then - print*,'bad 3d pt ',i,j,n,dummy_ceil3d(i,j,n),dummy_frac3d(i,j,n) - stop - endif - endif - - enddo - enddo - - enddo - - enddo - - enddo TILE - - print*,'DONE' - - end program check - - subroutine netcdf_err( err, string ) - - use netcdf - - implicit none - integer, intent(in) :: err - character(len=*), intent(in) :: string - character(len=256) :: errmsg - integer :: iret - - if( err.EQ.NF90_NOERR )return - errmsg = NF90_STRERROR(err) - print*,'' - print*,'FATAL ERROR: ', trim(string), ': ', trim(errmsg) - print*,'STOP.' - stop 6 - - return - end subroutine netcdf_err diff --git a/sorc/chgres_tools2.fd/CMakeLists.txt b/sorc/chgres_tools2.fd/CMakeLists.txt deleted file mode 100644 index 00299bfa1..000000000 --- a/sorc/chgres_tools2.fd/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -set(fortran_src - check.F90) - -if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8") -elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8") -endif() - -set(exe_name chgres_check2) -add_executable(${exe_name} ${fortran_src}) -target_link_libraries( - ${exe_name} - NetCDF::NetCDF_Fortran) - -install(TARGETS ${exe_name} RUNTIME DESTINATION ${exec_dir}) diff --git a/sorc/chgres_tools2.fd/check.F90 b/sorc/chgres_tools2.fd/check.F90 deleted file mode 100644 index 19f92edf5..000000000 --- a/sorc/chgres_tools2.fd/check.F90 +++ /dev/null @@ -1,300 +0,0 @@ - program check - -! How to use. -! -! 1) Run chgres in fractional grid mode. -! -! 2) Run chgres again using the updated orography files where 'slmsk' is -! updated to be 'floor(land fraction)'. Here chgres is run -! in non-fractional mode. -! -! 3) Compare the fields at non-land from (2) to the fields with some -! non-land from (1). They should match. - - use netcdf - - implicit none - - integer, parameter :: num_var=39 - integer, parameter :: num_var3d=1 - - character(len=150) :: file_floor, file_frac, file_orog_frac - - character(len=15) :: varname_frac(num_var), varname3d_frac(num_var3d) - character(len=15) :: varname_floor(num_var), varname3d_floor(num_var3d) - character(len=16) :: the_files(6) - character(len=21) :: oro_files(6) - - integer :: error, id_dim, idim, jdim, tiles - integer :: varid, varid_floor, varid_frac, var - integer :: i, j, n, ncid_floor, ncid_orog_frac, ncid_frac - - real*8, allocatable :: slmsk(:,:), land_frac(:,:), dummy_frac(:,:) - real*8, allocatable :: dummy_floor(:,:) - real*8, allocatable :: dummy_frac3d(:,:,:), dummy_floor3d(:,:,:) - - data varname_frac /'alvsf_nl', 'alvwf_nl', 'alnsf_nl', 'alnwf_nl', & - 'f10m', 'ffhh', 'ffmm', 'fice', 'hice', & - 'q2m', 'sheleg_ice', 'snwdph_ice', 'srflag', & - 't2m', 'tg3_ice', 'tisfc', 'tprcp', & - 'tsea', 'uustar', 'zorl_ice', 'zorl', & - 'c_0', 'c_d', 'd_conv', 'dt_cool', 'ifd', & - 'qrain', 'tref', 'w_0', 'w_d', 'xs', & - 'xt', 'xtts', 'xu', 'xv', 'xz', & - 'xzts', 'z_c', 'zm'/ - - data varname_floor /'alvsf', 'alvwf', 'alnsf', 'alnwf', & - 'f10m', 'ffhh', 'ffmm', 'fice', 'hice', & - 'q2m', 'sheleg', 'snwdph', 'srflag', & - 't2m', 'tg3', 'tisfc', 'tprcp', & - 'tsea', 'uustar', 'zorl', 'zorl', & - 'c_0', 'c_d', 'd_conv', 'dt_cool', 'ifd', & - 'qrain', 'tref', 'w_0', 'w_d', 'xs', & - 'xt', 'xtts', 'xu', 'xv', 'xz', & - 'xzts', 'z_c', 'zm'/ - - data varname3d_frac /'stc_ice'/ - - data varname3d_floor /'stc'/ - - data the_files /'out.sfc.tile1.nc', 'out.sfc.tile2.nc', 'out.sfc.tile3.nc', & - 'out.sfc.tile4.nc', 'out.sfc.tile5.nc', 'out.sfc.tile6.nc'/ - - data oro_files /'C96_oro_data.tile1.nc', 'C96_oro_data.tile2.nc', 'C96_oro_data.tile3.nc', & - 'C96_oro_data.tile4.nc', 'C96_oro_data.tile5.nc', 'C96_oro_data.tile6.nc' / - - do tiles = 1, 6 - - file_frac="/scratch2/NCEPDEV/stmp1/George.Gayno/chgres_fractional/" // the_files(tiles) - file_orog_frac="/scratch1/NCEPDEV/da/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & - // oro_files(tiles) - file_floor="/scratch2/NCEPDEV/stmp1/George.Gayno/chgres_floor/" // the_files(tiles) - -!file_frac="/gpfs/dell1/stmp/George.Gayno/chgres_fractional/" // the_files(tiles) -!file_orog_frac="/gpfs/dell2/emc/modeling/noscrub/George.Gayno/ufs_utils.git/chgres_cube.fractional/my_grids_fract/C96/" & -! // oro_files(tiles) -!file_floor="/gpfs/dell1/stmp/George.Gayno/chgres_floor/" // the_files(tiles) - -! Open the file created using the non-fractional logic, but with -! slmsk modified to be floor of the land fraction. - - print*,'- OPEN FILE ',trim(file_floor) - error=nf90_open(trim(file_floor),nf90_nowrite,ncid_floor) - call netcdf_err(error, 'opening file_floor' ) - - error=nf90_inq_dimid(ncid_floor, 'xaxis_1', id_dim) - call netcdf_err(error, 'getting xaxis' ) - error=nf90_inquire_dimension(ncid_floor,id_dim,len=idim) - call netcdf_err(error, 'reading xaxis' ) - - error=nf90_inq_dimid(ncid_floor, 'yaxis_1', id_dim) - call netcdf_err(error, 'getting yaxis' ) - error=nf90_inquire_dimension(ncid_floor,id_dim,len=jdim) - call netcdf_err(error, 'reading yaxis' ) - - if (.not. allocated(slmsk)) allocate(slmsk(idim,jdim)) - - error=nf90_inq_varid(ncid_floor,"slmsk",varid) - call netcdf_err(error, 'reading slmsk id' ) - error=nf90_get_var(ncid_floor,varid,slmsk) - call netcdf_err(error, 'reading slmsk' ) - - print*,'slmsk ',maxval(slmsk),minval(slmsk) - -! Open the fractional grid orography file. Read the -! land fraction. - - print*,'- OPEN FILE ',trim(file_orog_frac) - error=nf90_open(trim(file_orog_frac),nf90_nowrite,ncid_orog_frac) - call netcdf_err(error, 'opening file_orog_frac' ) - - if (.not. allocated(land_frac)) allocate(land_frac(idim,jdim)) - - error=nf90_inq_varid(ncid_orog_frac,"land_frac",varid_frac) - call netcdf_err(error, 'reading land_frac id' ) - error=nf90_get_var(ncid_orog_frac,varid_frac,land_frac) - call netcdf_err(error, 'reading land_frac' ) - - print*,'land_frac ',maxval(land_frac),minval(land_frac) - -! Are the land fraction from the fractional orography file -! and the 'floor' slmsk created from the non-fractional -! logic consistent with each other? - - do j = 1, jdim - do i = 1, idim - if (nint(slmsk(i,j)) == 0 .or. nint(slmsk(i,j)) == 2) then - if(floor(land_frac(i,j)) /= 0.0_8) then - print*,'bad mask point 1', i,j,slmsk(i,j),floor(land_frac(i,j)) - stop - endif - endif - if (floor(land_frac(i,j)) == 0.0_8) then - if (nint(slmsk(i,j)) == 1) then - print*,'bad mask point 2', i,j,slmsk(i,j),floor(land_frac(i,j)) - stop - endif - endif - enddo - enddo - -! Check data. - - if(.not.allocated(dummy_frac)) allocate(dummy_frac(idim,jdim)) - if(.not.allocated(dummy_floor)) allocate(dummy_floor(idim,jdim)) - - print*,'- OPEN FILE ',trim(file_frac) - error=nf90_open(trim(file_frac),nf90_nowrite,ncid_frac) - call netcdf_err(error, 'opening file_frac' ) - - print*,'process tile number ',tiles - - do var = 1, num_var - - print*,'CHECK FIELD ', trim(varname_frac(var)) - - error=nf90_inq_varid(ncid_frac, varname_frac(var), varid_frac) - call netcdf_err(error, 'reading frac id' ) - error=nf90_get_var(ncid_frac,varid_frac,dummy_frac) - call netcdf_err(error, 'reading frac field' ) - - print*,'frac field ',maxval(dummy_frac),minval(dummy_frac) - - error=nf90_inq_varid(ncid_floor, varname_floor(var), varid_floor) - call netcdf_err(error, 'reading floor id' ) - error=nf90_get_var(ncid_floor,varid_floor,dummy_floor) - call netcdf_err(error, 'reading floor field' ) - - if (trim(varname_floor(var)) == 'fice') then - where(dummy_floor > 0.95) dummy_floor = 1.00 - endif - - print*,'floor field ',maxval(dummy_floor),minval(dummy_floor) - - if (trim(varname_frac(var)) == 'tg3_ice' .or. & - trim(varname_frac(var)) == 'tisfc' .or. & - trim(varname_frac(var)) == 'snwdph_ice' .or. & - trim(varname_frac(var)) == 'sheleg_ice' .or. & - trim(varname_frac(var)) == 'zorl_ice') then ! check at ice only. - do j = 1, jdim - do i = 1, idim - if (nint(slmsk(i,j)) == 2) then - if (dummy_floor(i,j) /= dummy_frac(i,j)) then - print*,'bad ice pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) - stop - endif - endif - enddo - enddo - elseif (trim(varname_frac(var)) == 'zorl' .or. & - trim(varname_frac(var)) == 'tsea' .or. & - trim(varname_frac(var)) == 'c_0' .or. & - trim(varname_frac(var)) == 'c_d' .or. & - trim(varname_frac(var)) == 'd_conv' .or. & - trim(varname_frac(var)) == 'dt_cool' .or. & - trim(varname_frac(var)) == 'qrain' .or. & - trim(varname_frac(var)) == 'w_0' .or. & - trim(varname_frac(var)) == 'w_d' .or. & - trim(varname_frac(var)) == 'xs' .or. & - trim(varname_frac(var)) == 'xt' .or. & - trim(varname_frac(var)) == 'xtts' .or. & - trim(varname_frac(var)) == 'xu' .or. & - trim(varname_frac(var)) == 'xv' .or. & - trim(varname_frac(var)) == 'xz' .or. & - trim(varname_frac(var)) == 'xzts' .or. & - trim(varname_frac(var)) == 'z_c' .or. & - trim(varname_frac(var)) == 'zm' .or. & - trim(varname_frac(var)) == 'tref') then ! check at open water only. - do j = 1, jdim - do i = 1, idim - if (nint(slmsk(i,j)) == 0) then - if (dummy_floor(i,j) /= dummy_frac(i,j)) then - print*,'bad water pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) - stop - endif - endif - enddo - enddo - else ! Check at ice and open water. - do j = 1, jdim - do i = 1, idim - if (nint(slmsk(i,j)) == 0 .or. nint(slmsk(i,j)) == 2) then - if (dummy_floor(i,j) /= dummy_frac(i,j)) then - print*,'bad pt ',i,j,dummy_floor(i,j),dummy_frac(i,j) - stop - endif - endif - enddo - enddo - endif - - enddo - - if(.not.allocated(dummy_frac3d)) allocate(dummy_frac3d(idim,jdim,2)) - if(.not.allocated(dummy_floor3d)) allocate(dummy_floor3d(idim,jdim,4)) - - do var = 1, num_var3d - - print*,'CHECK FIELD ', trim(varname3d_frac(var)) - - error=nf90_inq_varid(ncid_frac, varname3d_frac(var), varid_frac) - call netcdf_err(error, 'reading frac id' ) - error=nf90_get_var(ncid_frac,varid_frac,dummy_frac3d) - call netcdf_err(error, 'reading frac field' ) - - error=nf90_inq_varid(ncid_floor, varname3d_floor(var), varid_floor) - call netcdf_err(error, 'reading floor id' ) - error=nf90_get_var(ncid_floor,varid_floor,dummy_floor3d) - call netcdf_err(error, 'reading floor field' ) - - do n = 1, 2 - - print*,'frac field level ',n,maxval(dummy_frac3d(:,:,n)),minval(dummy_frac3d(:,:,n)) - print*,'floor field level ',n,maxval(dummy_floor3d(:,:,n)),minval(dummy_floor3d(:,:,n)) - - do j = 1, jdim - do i = 1, idim - - if (nint(slmsk(i,j)) == 2) then - if (dummy_floor3d(i,j,n) /= dummy_frac3d(i,j,n)) then - print*,'bad 3d pt ',i,j,n,dummy_floor3d(i,j,n),dummy_frac3d(i,j,n) - stop - endif - endif - - enddo - enddo - - enddo - - enddo - - error=nf90_close(ncid_floor) - error=nf90_close(ncid_orog_frac) - error=nf90_close(ncid_frac) - - enddo - - print*,'DONE' - - end program check - - subroutine netcdf_err( err, string ) - - use netcdf - - implicit none - integer, intent(in) :: err - character(len=*), intent(in) :: string - character(len=256) :: errmsg - integer :: iret - - if( err.EQ.NF90_NOERR )return - errmsg = NF90_STRERROR(err) - print*,'' - print*,'FATAL ERROR: ', trim(string), ': ', trim(errmsg) - print*,'STOP.' - stop 6 - - return - end subroutine netcdf_err From 2fb83429353a66d29c185cf44888d08e859fe118 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 12 Jan 2024 13:36:31 +0000 Subject: [PATCH 103/107] Remove c96 regional test case from Jet driver script. Fixes #123. --- reg_tests/chgres_cube/driver.jet.sh | 55 ++++++++++++----------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/reg_tests/chgres_cube/driver.jet.sh b/reg_tests/chgres_cube/driver.jet.sh index 813f13cfe..77bc07e31 100755 --- a/reg_tests/chgres_cube/driver.jet.sh +++ b/reg_tests/chgres_cube/driver.jet.sh @@ -111,112 +111,103 @@ export OMP_NUM_THREADS=1 TEST5=$(sbatch --parsable --partition=xjet --nodes=1 --ntasks-per-node=6 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J c96.gfs.nemsio \ --exclusive -o $LOG_FILE -e $LOG_FILE ./c96.gfs.nemsio.sh) -#----------------------------------------------------------------------------- -# Initialize regional C96 using FV3 gaussian nemsio files. -#----------------------------------------------------------------------------- - -LOG_FILE=consistency.log06 -export OMP_NUM_THREADS=1 -TEST6=$(sbatch --parsable --partition=xjet --nodes=1 --ntasks-per-node=6 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J c96.regional \ - --exclusive -o $LOG_FILE -e $LOG_FILE ./c96.regional.sh) - #----------------------------------------------------------------------------- # Initialize C96 using FV3 gaussian netcdf files. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log07 +LOG_FILE=consistency.log06 export OMP_NUM_THREADS=1 -TEST7=$(sbatch --parsable --partition=xjet --nodes=2 --ntasks-per-node=6 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J c96.fv3.netcdf \ +TEST6=$(sbatch --parsable --partition=xjet --nodes=2 --ntasks-per-node=6 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J c96.fv3.netcdf \ --exclusive -o $LOG_FILE -e $LOG_FILE ./c96.fv3.netcdf.sh) #----------------------------------------------------------------------------- # Initialize C192 using GFS GRIB2 data. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log08 +LOG_FILE=consistency.log07 export OMP_NUM_THREADS=1 -TEST8=$(sbatch --parsable --partition=xjet --nodes=1 --ntasks-per-node=6 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c192.gfs.grib2 \ +TEST7=$(sbatch --parsable --partition=xjet --nodes=1 --ntasks-per-node=6 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c192.gfs.grib2 \ --exclusive -o $LOG_FILE -e $LOG_FILE ./c192.gfs.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 25-KM USING GFS GRIB2 files. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log09 +LOG_FILE=consistency.log08 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST9=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.grib2.conus \ +TEST8=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.grib2.conus \ --exclusive -o $LOG_FILE -e $LOG_FILE ./25km.conus.gfs.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 3-KM USING HRRR GRIB2 file WITH GFS PHYSICS. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log10 +LOG_FILE=consistency.log09 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST10=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=2 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 3km.conus.hrrr.gfssdf.grib2.conus \ +TEST9=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=2 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 3km.conus.hrrr.gfssdf.grib2.conus \ --exclusive -o $LOG_FILE -e $LOG_FILE ./3km.conus.hrrr.gfssdf.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 3-KM USING HRRR GRIB2 file WITH GSD PHYSICS AND SFC VARS FROM FILE. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log11 +LOG_FILE=consistency.log10 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST11=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=3 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 3km.conus.hrrr.newsfc.grib2.conus \ +TEST10=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=3 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 3km.conus.hrrr.newsfc.grib2.conus \ --exclusive -o $LOG_FILE -e $LOG_FILE ./3km.conus.hrrr.newsfc.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 13-KM USING NAM GRIB2 file WITH GFS PHYSICS . #----------------------------------------------------------------------------- -LOG_FILE=consistency.log12 +LOG_FILE=consistency.log11 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST12=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 13km.conus.nam.grib2.conus \ +TEST11=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 13km.conus.nam.grib2.conus \ --exclusive -o $LOG_FILE -e $LOG_FILE ./13km.conus.nam.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 13-KM USING RAP GRIB2 file WITH GSD PHYSICS . #----------------------------------------------------------------------------- -LOG_FILE=consistency.log13 +LOG_FILE=consistency.log12 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST13=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 13km.conus.rap.grib2.conus \ +TEST12=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 13km.conus.rap.grib2.conus \ --exclusive -o $LOG_FILE -e $LOG_FILE ./13km.conus.rap.grib2.sh) #----------------------------------------------------------------------------- # Initialize CONUS 13-KM NA USING NCEI GFS GRIB2 file WITH GFS PHYSICS . #----------------------------------------------------------------------------- -LOG_FILE=consistency.log14 +LOG_FILE=consistency.log13 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST14=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=2 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 13km.na.gfs.ncei.grib2.conus \ +TEST13=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=2 -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 13km.na.gfs.ncei.grib2.conus \ --exclusive -o $LOG_FILE -e $LOG_FILE ./13km.na.gfs.ncei.grib2.sh) #----------------------------------------------------------------------------- # Initialize C96 WAM IC using FV3 gaussian netcdf files. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log15 +LOG_FILE=consistency.log14 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST15=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=2 -t 0:15:00 -A $PROJECT_CODE -q $QUEUE -J c96.fv3.netcdf2wam \ +TEST14=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=2 -t 0:15:00 -A $PROJECT_CODE -q $QUEUE -J c96.fv3.netcdf2wam \ --exclusive -o $LOG_FILE -e $LOG_FILE ./c96.fv3.netcdf2wam.sh) #----------------------------------------------------------------------------- # Initialize CONUS 25-KM USING GFS PGRIB2+BGRIB2 files. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log16 +LOG_FILE=consistency.log15 export OMP_NUM_THREADS=1 # should match cpus-per-task -TEST16=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.pbgrib2.conus \ +TEST15=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.pbgrib2.conus \ --exclusive -o $LOG_FILE -e $LOG_FILE ./25km.conus.gfs.pbgrib2.sh) #----------------------------------------------------------------------------- # Initialize C96 using GEFS GRIB2 data. #----------------------------------------------------------------------------- -LOG_FILE=consistency.log17 +LOG_FILE=consistency.log16 export OMP_NUM_THREADS=1 -TEST17=$(sbatch --parsable --partition=xjet --nodes=1 --ntasks-per-node=6 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c96.gefs.grib2 \ +TEST16=$(sbatch --parsable --partition=xjet --nodes=1 --ntasks-per-node=6 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c96.gefs.grib2 \ --exclusive -o $LOG_FILE -e $LOG_FILE ./c96.gefs.grib2.sh) #----------------------------------------------------------------------------- @@ -226,7 +217,7 @@ TEST17=$(sbatch --parsable --partition=xjet --nodes=1 --ntasks-per-node=6 -t 0:0 LOG_FILE=consistency.log sbatch --partition=xjet --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J chgres_summary -o $LOG_FILE -e $LOG_FILE \ --open-mode=append -q $QUEUE -d\ - afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16:$TEST17 << EOF + afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16 << EOF #!/bin/bash grep -a '<<<' $LOG_FILE* > $SUM_FILE EOF From 1ab0c29327e82de358d0deb0397b56a184c49e11 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 12 Jan 2024 12:20:00 -0600 Subject: [PATCH 104/107] Remove c96 regional case from orion driver script. Fixes #123. --- reg_tests/chgres_cube/driver.orion.sh | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/reg_tests/chgres_cube/driver.orion.sh b/reg_tests/chgres_cube/driver.orion.sh index 011dd0fba..df66171ac 100755 --- a/reg_tests/chgres_cube/driver.orion.sh +++ b/reg_tests/chgres_cube/driver.orion.sh @@ -115,13 +115,13 @@ TEST5=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 --mem=75G -t 0:15:00 -A --open-mode=append -o $LOG_FILE5 -e $LOG_FILE5 ./c96.gfs.nemsio.sh) #----------------------------------------------------------------------------- -# Initialize regional C96 using FV3 gaussian nemsio files. +# Initialize C96 using GEFS GRIB2 file. #----------------------------------------------------------------------------- LOG_FILE6=${LOG_FILE}06 export OMP_NUM_THREADS=1 # needs to match cpus-per-task -TEST6=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 --mem=75G -t 0:15:00 -A $PROJECT_CODE -q $QUEUE -J c96.regional \ - --open-mode=append -o $LOG_FILE6 -e $LOG_FILE6 ./c96.regional.sh) +TEST6=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 --mem=75G -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c96.gefs.grib2 \ + --open-mode=append -o $LOG_FILE6 -e $LOG_FILE6 ./c96.gefs.grib2.sh) #----------------------------------------------------------------------------- # Initialize global C192 using GFS GRIB2 files. @@ -213,22 +213,13 @@ export OMP_NUM_THREADS=1 # should match cpus-per-task TEST16=$(sbatch --parsable --ntasks-per-node=12 --nodes=1 --mem=75G -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.pbgrib2 \ --open-mode=append -o $LOG_FILE16 -e $LOG_FILE16 ./25km.conus.gfs.pbgrib2.sh) -#----------------------------------------------------------------------------- -# Initialize C96 using GEFS GRIB2 file. -#----------------------------------------------------------------------------- - -LOG_FILE17=${LOG_FILE}17 -export OMP_NUM_THREADS=1 # needs to match cpus-per-task -TEST17=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 --mem=75G -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c96.gefs.grib2 \ - --open-mode=append -o $LOG_FILE17 -e $LOG_FILE17 ./c96.gefs.grib2.sh) - #----------------------------------------------------------------------------- # Create summary log. #----------------------------------------------------------------------------- sbatch --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J chgres_summary -o $LOG_FILE -e $LOG_FILE \ --open-mode=append -q $QUEUE \ - -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16:$TEST17 << EOF + -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16 << EOF #!/bin/bash grep -a '<<<' ${LOG_FILE}* > $SUM_FILE EOF From 13a88babd3b624237411ffe4122293ccd5fb9b50 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Fri, 12 Jan 2024 12:29:08 -0600 Subject: [PATCH 105/107] Remove c96 regional test case from hercules driver script. Fixes #123. --- reg_tests/chgres_cube/driver.hercules.sh | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/reg_tests/chgres_cube/driver.hercules.sh b/reg_tests/chgres_cube/driver.hercules.sh index 177943574..d9a6a8358 100755 --- a/reg_tests/chgres_cube/driver.hercules.sh +++ b/reg_tests/chgres_cube/driver.hercules.sh @@ -34,7 +34,7 @@ module list ulimit -s unlimited -export OUTDIR="${WORK_DIR:-/work/noaa/stmp/$LOGNAME}" +export OUTDIR="${WORK_DIR:-/work2/noaa/stmp/$LOGNAME}" export OUTDIR="${OUTDIR}/reg-tests/chgres-cube" PROJECT_CODE="${PROJECT_CODE:-fv3-cpu}" @@ -117,13 +117,13 @@ TEST5=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 --mem=75G -t 0:15:00 -A --open-mode=append -o $LOG_FILE5 -e $LOG_FILE5 ./c96.gfs.nemsio.sh) #----------------------------------------------------------------------------- -# Initialize regional C96 using FV3 gaussian nemsio files. +# Initialize C96 using GEFS GRIB2 file. #----------------------------------------------------------------------------- LOG_FILE6=${LOG_FILE}06 export OMP_NUM_THREADS=1 # needs to match cpus-per-task -TEST6=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 --mem=75G -t 0:15:00 -A $PROJECT_CODE -q $QUEUE -J c96.regional \ - --open-mode=append -o $LOG_FILE6 -e $LOG_FILE6 ./c96.regional.sh) +TEST6=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 --mem=75G -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c96.gefs.grib2 \ + --open-mode=append -o $LOG_FILE6 -e $LOG_FILE6 ./c96.gefs.grib2.sh) #----------------------------------------------------------------------------- # Initialize global C192 using GFS GRIB2 files. @@ -215,22 +215,13 @@ export OMP_NUM_THREADS=1 # should match cpus-per-task TEST16=$(sbatch --parsable --ntasks-per-node=12 --nodes=1 --mem=75G -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.pbgrib2 \ --open-mode=append -o $LOG_FILE16 -e $LOG_FILE16 ./25km.conus.gfs.pbgrib2.sh) -#----------------------------------------------------------------------------- -# Initialize C96 using GEFS GRIB2 file. -#----------------------------------------------------------------------------- - -LOG_FILE17=${LOG_FILE}17 -export OMP_NUM_THREADS=1 # needs to match cpus-per-task -TEST17=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 --mem=75G -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c96.gefs.grib2 \ - --open-mode=append -o $LOG_FILE17 -e $LOG_FILE17 ./c96.gefs.grib2.sh) - #----------------------------------------------------------------------------- # Create summary log. #----------------------------------------------------------------------------- sbatch --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J chgres_summary -o $LOG_FILE -e $LOG_FILE \ --open-mode=append -q $QUEUE \ - -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16:$TEST17 << EOF + -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16 << EOF #!/bin/bash grep -a '<<<' ${LOG_FILE}* > $SUM_FILE EOF From ed72fb13fd84fcf1c75435d950243b2e3cca5182 Mon Sep 17 00:00:00 2001 From: "George.Gayno" Date: Fri, 12 Jan 2024 19:09:41 +0000 Subject: [PATCH 106/107] Remove c96 regional case from wcoss2 driver script. Fixes #123. --- reg_tests/chgres_cube/driver.wcoss2.sh | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/reg_tests/chgres_cube/driver.wcoss2.sh b/reg_tests/chgres_cube/driver.wcoss2.sh index 6ae0efb48..2638b3f6d 100755 --- a/reg_tests/chgres_cube/driver.wcoss2.sh +++ b/reg_tests/chgres_cube/driver.wcoss2.sh @@ -113,13 +113,13 @@ TEST5=$(qsub -V -o $LOG_FILE -e $LOG_FILE -q $QUEUE -A $PROJECT_CODE -l walltime -N c96.gfs.nemsio -l select=1:ncpus=6:ompthreads=1:mem=35GB $PWD/c96.gfs.nemsio.sh) #----------------------------------------------------------------------------- -# Initialize regional C96 using FV3 gaussian nemsio files. +# Initialize global C96 using GEFS GRIB2 files. #----------------------------------------------------------------------------- LOG_FILE=consistency.log06 export APRUN="mpiexec -n 6 -ppn 6 --cpu-bind core" TEST6=$(qsub -V -o $LOG_FILE -e $LOG_FILE -q $QUEUE -A $PROJECT_CODE -l walltime=00:05:00 \ - -N c96.regional -l select=1:ncpus=6:ompthreads=1:mem=35GB $PWD/c96.regional.sh) + -N c96.gefs.grib2 -l select=1:ncpus=6:ompthreads=1:mem=15GB $PWD/c96.gefs.grib2.sh) #----------------------------------------------------------------------------- # Initialize C96 using FV3 gaussian netcdf files. @@ -211,15 +211,6 @@ export APRUN="mpiexec -n 6 -ppn 6 --cpu-bind core" TEST16=$(qsub -V -o $LOG_FILE -e $LOG_FILE -q $QUEUE -A $PROJECT_CODE -l walltime=00:05:00 \ -N 25km.conus.gfs.pbgrib2.conus -l select=1:ncpus=6:ompthreads=1:mem=15GB $PWD/25km.conus.gfs.pbgrib2.sh) -#----------------------------------------------------------------------------- -# Initialize global C96 using GEFS GRIB2 files. -#----------------------------------------------------------------------------- - -LOG_FILE=consistency.log17 -export APRUN="mpiexec -n 6 -ppn 6 --cpu-bind core" -TEST17=$(qsub -V -o $LOG_FILE -e $LOG_FILE -q $QUEUE -A $PROJECT_CODE -l walltime=00:05:00 \ - -N c96.gefs.grib2 -l select=1:ncpus=6:ompthreads=1:mem=15GB $PWD/c96.gefs.grib2.sh) - #----------------------------------------------------------------------------- # Create summary log. #----------------------------------------------------------------------------- @@ -227,7 +218,7 @@ TEST17=$(qsub -V -o $LOG_FILE -e $LOG_FILE -q $QUEUE -A $PROJECT_CODE -l walltim LOG_FILE=consistency.log qsub -V -o ${LOG_FILE} -e ${LOG_FILE} -q $QUEUE -A $PROJECT_CODE -l walltime=00:01:00 \ -N chgres_summary -l select=1:ncpus=1:mem=100MB \ - -W depend=afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16:$TEST17 << EOF + -W depend=afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16 << EOF #!/bin/bash cd ${this_dir} grep -a '<<<' ${LOG_FILE}?? | grep -v echo > $SUM_FILE From fb980713dceab1c1581cfc3f2046916e89fe05c2 Mon Sep 17 00:00:00 2001 From: George Gayno Date: Thu, 18 Jan 2024 08:02:03 -0600 Subject: [PATCH 107/107] Update the grid_gen test driver script to use a different working directory than the one used by the orion script. Fixes #123. --- reg_tests/grid_gen/driver.hercules.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reg_tests/grid_gen/driver.hercules.sh b/reg_tests/grid_gen/driver.hercules.sh index 3c46a2d45..5f4a81478 100755 --- a/reg_tests/grid_gen/driver.hercules.sh +++ b/reg_tests/grid_gen/driver.hercules.sh @@ -30,7 +30,7 @@ module list set -x ulimit -s unlimited -export WORK_DIR="${WORK_DIR:-/work/noaa/stmp/$LOGNAME}" +WORK_DIR="${WORK_DIR:-/work2/noaa/stmp/$LOGNAME}" export WORK_DIR="${WORK_DIR}/reg-tests/grid-gen" QUEUE="${QUEUE:-batch}" PROJECT_CODE=${PROJECT_CODE:-fv3-cpu}