Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify initialization of soil state #344

Merged
merged 7 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CaMa/src/MOD_CaMa_Vars.F90
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ SUBROUTINE flux_map_and_write_2d_cama (is_hist, &
IF (itime_in_file == 1) THEN
CALL ncio_put_attr (file_hist, varname, 'long_name', longname)
CALL ncio_put_attr (file_hist, varname, 'units', units)
CALL ncio_put_attr (file_hist, varname, 'missing_value',spval)
CALL ncio_put_attr (file_hist, varname, 'missing_value',real(real(spval,kind=JPRM),kind=8))
ENDIF

END SUBROUTINE flux_map_and_write_2d_cama
Expand Down
30 changes: 27 additions & 3 deletions CaMa/src/MOD_CaMa_colmCaMa.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ MODULE MOD_CaMa_colmCaMa
USE CMF_CTRL_OUTPUT_MOD, only: CMF_OUTPUT_INIT,CMF_OUTPUT_END,NVARSOUT,VAROUT
USE YOS_CMF_INPUT, only: NXIN, NYIN, DT,DTIN,IFRQ_INP,LLEAPYR,NX,NY,RMIS,DMIS
USE MOD_Precision, only: r8,r4
USE YOS_CMF_INPUT , only: LROSPLIT,LWEVAP,LWINFILT
USE YOS_CMF_INPUT , only: LROSPLIT,LWEVAP,LWINFILT,CSETFILE
USE YOS_CMF_MAP, only: D1LON, D1LAT
USE YOS_CMF_INPUT, only: WEST,EAST,NORTH,SOUTH

Expand Down Expand Up @@ -73,6 +73,11 @@ SUBROUTINE colm_CaMa_init
#ifdef USEMPI
CALL mpi_barrier (p_comm_glb, p_err)
#endif

IF (p_is_master) THEN

CSETFILE = DEF_CaMa_Namelist

!Namelist handling
CALL CMF_DRV_INPUT
!get the time information from colm namelist
Expand Down Expand Up @@ -181,14 +186,33 @@ SUBROUTINE colm_CaMa_init
END SELECT
ENDDO

ENDIF

!Broadcast the variables to all the processors
CALL mpi_bcast (NX , 1, MPI_INTEGER, p_address_master, p_comm_glb, p_err) ! number of grid points in x-direction of CaMa-Flood
CALL mpi_bcast (NY , 1, MPI_INTEGER, p_address_master, p_comm_glb, p_err) ! number of grid points in y-direction of CaMa-Flood
CALL mpi_bcast (IFRQ_INP , 1, MPI_INTEGER, p_address_master, p_comm_glb, p_err) ! input frequency of CaMa-Flood (hour)
CALL mpi_bcast (LWEVAP , 1, MPI_LOGICAL, p_address_master, p_comm_glb, p_err) ! switch for inundation evaporation
CALL mpi_bcast (LWINFILT , 1, MPI_LOGICAL, p_address_master, p_comm_glb, p_err) ! switch for inundation re-infiltration
CALL mpi_bcast (real(D1LAT,kind=8) , 1, MPI_REAL8, p_address_master, p_comm_glb, p_err) !
CALL mpi_bcast (real(D1LON,kind=8) , 1, MPI_REAL8, p_address_master, p_comm_glb, p_err) !

IF (.not. allocated(D1LAT)) allocate (D1LAT(NY))
IF (.not. allocated(D1LON)) allocate (D1LON(NX))

#ifdef SinglePrec_CMF
CALL mpi_bcast (D1LAT, NY, MPI_REAL4, p_address_master, p_comm_glb, p_err) !
CALL mpi_bcast (D1LON, NX, MPI_REAL4, p_address_master, p_comm_glb, p_err) !
CALL mpi_bcast (SOUTH, 1, MPI_REAL4, p_address_master, p_comm_glb, p_err) !
CALL mpi_bcast (NORTH, 1, MPI_REAL4, p_address_master, p_comm_glb, p_err) !
CALL mpi_bcast (WEST , 1, MPI_REAL4, p_address_master, p_comm_glb, p_err) !
CALL mpi_bcast (EAST , 1, MPI_REAL4, p_address_master, p_comm_glb, p_err) !
#else
CALL mpi_bcast (D1LAT, NY, MPI_REAL8, p_address_master, p_comm_glb, p_err) !
CALL mpi_bcast (D1LON, NX, MPI_REAL8, p_address_master, p_comm_glb, p_err) !
CALL mpi_bcast (SOUTH, 1, MPI_REAL8, p_address_master, p_comm_glb, p_err) !
CALL mpi_bcast (NORTH, 1, MPI_REAL8, p_address_master, p_comm_glb, p_err) !
CALL mpi_bcast (WEST , 1, MPI_REAL8, p_address_master, p_comm_glb, p_err) !
CALL mpi_bcast (EAST , 1, MPI_REAL8, p_address_master, p_comm_glb, p_err) !
#endif

!allocate the data structure for cama
CALL gcama%define_by_center (D1LAT,D1LON,real(SOUTH,kind=8), real(NORTH,kind=8), real(WEST,kind=8), real(EAST,kind=8)) !define the grid for cama
Expand Down
2 changes: 1 addition & 1 deletion CaMa/src/yos_cmf_input.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ MODULE YOS_CMF_INPUT
character(LEN=256) :: CSETFILE !! input namelist file name

DATA LLOGOUT /.TRUE./
DATA CLOGOUT /'../run/log_CaMa.txt'/
DATA CLOGOUT /'./log_CaMa.txt'/
DATA CSETFILE /'../run/cama_flood.nml'/

!================================================
Expand Down
21 changes: 11 additions & 10 deletions main/HYDRO/MOD_Catch_RiverLakeFlow.F90
Original file line number Diff line number Diff line change
Expand Up @@ -454,21 +454,22 @@ SUBROUTINE river_lake_flow (dt)
momen_riv_ta(:) = momen_riv_ta(:) + momen_riv(:) * dt_this
discharge (:) = discharge (:) + hflux_fc (:) * dt_this
ENDIF

DO i = 1, nbasin
IF (lake_id(i) > 0) THEN ! for lakes
hs = basin_hru%substt(i)
he = basin_hru%subend(i)
DO j = hs, he
wdsrf_hru(j) = max(wdsrf_bsn(i) - (lakes(i)%depth(1) - lakes(i)%depth0(j-hs+1)), 0.)
wdsrf_hru_ta(j) = wdsrf_hru_ta(j) + wdsrf_hru(j) * dt_this
ENDDO
ENDIF
ENDDO

dt_res = dt_res - dt_this

ENDDO

DO i = 1, nbasin
IF (lake_id(i) > 0) THEN ! for lakes
hs = basin_hru%substt(i)
he = basin_hru%subend(i)
DO j = hs, he
wdsrf_hru(j) = max(wdsrf_bsn(i) - (lakes(i)%depth(1) - lakes(i)%depth0(j-hs+1)), 0.)
ENDDO
ENDIF
ENDDO

wdsrf_bsn_prev(:) = wdsrf_bsn(:)

IF (allocated(wdsrf_bsn_ds )) deallocate(wdsrf_bsn_ds )
Expand Down
3 changes: 3 additions & 0 deletions main/HYDRO/MOD_Catch_RiverLakeNetwork.F90
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@ SUBROUTINE river_lake_network_init ()

IF (inb <= 0) THEN
outletwth(ibasin) = 0
IF (riverdown(ibasin) > 0) THEN
outletwth(ibasin) = 90.
ENDIF
ELSE
outletwth(ibasin) = elementneighbour(ibasin)%lenbdr(inb)
ENDIF
Expand Down
33 changes: 23 additions & 10 deletions mkinidata/MOD_Initialize.F90
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,15 @@ SUBROUTINE initialize (casename, dir_landdata, dir_restart, &
IF (DEF_USE_SoilInit) THEN

fsoildat = DEF_file_SoilInit

IF (p_is_master) THEN
inquire (file=trim(fsoildat), exist=use_soilini)
IF (use_soilini) THEN
write(*,'(/,2A)') 'Use soil water content, soil temperature and water table depth ' &
// 'to initialize soil state from file ', trim(fsoildat)
ELSE
write(*,*) 'No initial data for soil state from ', trim(fsoildat)
ENDIF
ENDIF
#ifdef USEMPI
CALL mpi_bcast (use_soilini, 1, MPI_LOGICAL, p_address_master, p_comm_glb, p_err)
Expand Down Expand Up @@ -1083,19 +1090,25 @@ SUBROUTINE initialize (casename, dir_landdata, dir_restart, &


! for SOIL Water INIT by using water table depth
fwtd = trim(DEF_dir_runtime) // '/wtd.nc'
IF (p_is_master) THEN
inquire (file=trim(fwtd), exist=use_wtd)
IF (use_soilini) use_wtd = .false.
IF (use_wtd) THEN
write(*,'(/, 2A)') 'Use water table depth and derived equilibrium state ' &
// ' to initialize soil water content: ', trim(fwtd)
ENDIF
ENDIF
use_wtd = (.not. use_soilini) .and. DEF_USE_WaterTableInit

IF (use_wtd) THEN

fwtd = DEF_file_WaterTable

IF (p_is_master) THEN
inquire (file=trim(fwtd), exist=use_wtd)
IF (use_wtd) THEN
write(*,'(/, 2A)') 'Use water table depth and derived equilibrium state ' &
// ' to initialize soil water content from file ', trim(fwtd)
ELSE
write(*,*) 'No initial data for water table depth from ', trim(fwtd)
ENDIF
ENDIF
#ifdef USEMPI
CALL mpi_bcast (use_wtd, 1, MPI_LOGICAL, p_address_master, p_comm_glb, p_err)
CALL mpi_bcast (use_wtd, 1, MPI_LOGICAL, p_address_master, p_comm_glb, p_err)
#endif
ENDIF

IF (use_wtd) THEN

Expand Down
25 changes: 25 additions & 0 deletions share/MOD_Namelist.F90
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ MODULE MOD_Namelist
logical :: DEF_USE_CN_INIT = .false.
character(len=256) :: DEF_file_cn_init = 'null'

logical :: DEF_USE_WaterTableInit = .false.
character(len=256) :: DEF_file_WaterTable = 'null'

! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! ----- Part 9: LULCC related ------
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -301,6 +304,9 @@ MODULE MOD_Namelist
!2: To allow monthly ndep data to be read in
integer :: DEF_NDEP_FREQUENCY = 1

! ----- CaMa-Flood -----
character(len=256) :: DEF_CaMa_Namelist = 'null'

! ----- lateral flow related -----
logical :: DEF_USE_EstimatedRiverDepth = .true.
character(len=256) :: DEF_ElementNeighbour_file = 'null'
Expand Down Expand Up @@ -993,9 +999,14 @@ SUBROUTINE read_namelist (nlfile)
DEF_USE_CN_INIT, &
DEF_file_cn_init, &

DEF_USE_WaterTableInit, &
DEF_file_WaterTable, &

DEF_file_snowoptics, &
DEF_file_snowaging , &

DEF_CaMa_Namelist, &

DEF_ElementNeighbour_file, &

DEF_DA_obsdir, &
Expand Down Expand Up @@ -1305,6 +1316,15 @@ SUBROUTINE read_namelist (nlfile)
#endif
#endif

! ----- Soil water and temperature Initialization ----- Namelist conflicts

IF (DEF_USE_SoilInit .and. DEF_USE_WaterTableInit) THEN
write(*,*) ' ***** '
write(*,*) 'If both DEF_USE_SoilInit and DEF_USE_WaterTableInit are .TRUE., '
write(*,*) 'initial value of water table depth is read from DEF_file_SoilInit,'
write(*,*) 'instead of DEF_file_WaterTable (which is useless in this CASE). '
ENDIF

! ----- dynamic lake run ----- Macros&Namelist conflicts and dependency management

#ifndef CATCHMENT
Expand Down Expand Up @@ -1477,10 +1497,15 @@ SUBROUTINE read_namelist (nlfile)
CALL mpi_bcast (DEF_USE_CN_INIT ,1 ,mpi_logical ,p_address_master ,p_comm_glb ,p_err)
CALL mpi_bcast (DEF_file_cn_init ,256 ,mpi_character ,p_address_master ,p_comm_glb ,p_err)

CALL mpi_bcast (DEF_USE_WaterTableInit ,1 ,mpi_logical ,p_address_master ,p_comm_glb ,p_err)
CALL mpi_bcast (DEF_file_WaterTable ,256 ,mpi_character ,p_address_master ,p_comm_glb ,p_err)

CALL mpi_bcast (DEF_USE_SNICAR ,1 ,mpi_logical ,p_address_master ,p_comm_glb ,p_err)
CALL mpi_bcast (DEF_file_snowoptics ,256 ,mpi_character ,p_address_master ,p_comm_glb ,p_err)
CALL mpi_bcast (DEF_file_snowaging ,256 ,mpi_character ,p_address_master ,p_comm_glb ,p_err)

CALL mpi_bcast (DEF_CaMa_Namelist ,256 ,mpi_character ,p_address_master ,p_comm_glb ,p_err)

CALL mpi_bcast (DEF_ElementNeighbour_file ,256 ,mpi_character ,p_address_master ,p_comm_glb ,p_err)

CALL mpi_bcast (DEF_DA_obsdir ,256 ,mpi_character ,p_address_master ,p_comm_glb ,p_err)
Expand Down
Loading