Skip to content

Commit

Permalink
add AWICM forcing
Browse files Browse the repository at this point in the history
  • Loading branch information
LAWTIDEBOY committed Sep 12, 2024
1 parent 4ef4d5b commit daa02d4
Show file tree
Hide file tree
Showing 3 changed files with 988 additions and 36 deletions.
83 changes: 48 additions & 35 deletions src/gen_surface_forcing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -114,34 +114,34 @@ MODULE g_sbf
logical :: ic_cyclic=.true.
!============== namelistatmdata variables ================
integer, save :: nm_sbc = 1 ! data 1= constant, 2=from file
character(len=256), save :: nm_xwind_file = 'xwind.dat' ! name of file with winds/stress, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_ywind_file = 'ywind.dat' ! name of file with winds/stress, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_humi_file = 'humidity.dat' ! name of file with humidity, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_qsr_file = 'qsr.dat' ! name of file with solar heat, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_qlw_file = 'qlw.dat' ! name of file with Long wave, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_tair_file = 'tair.dat' ! name of file with 2m air temperature, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_prec_file = 'prec.dat' ! name of file with total precipitation, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_snow_file = 'snow.dat' ! name of file with snow precipitation, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_mslp_file = 'mslp.dat' ! name of file with mean sea level pressure, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_cloud_file = 'cloud.dat' ! name of file with clouds, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model

character(len=34), save :: nm_xwind_var = 'uwnd' ! name of variable in file with wind
character(len=34), save :: nm_ywind_var = 'vwnd' ! name of variable in file with wind
character(len=34), save :: nm_humi_var = 'shum' ! name of variable in file with humidity
character(len=34), save :: nm_qsr_var = 'dswrf'! name of variable in file with solar heat
character(len=34), save :: nm_qlw_var = 'dlwrf'! name of variable in file with Long wave
character(len=34), save :: nm_tair_var = 'air' ! name of variable in file with 2m air temperature
character(len=34), save :: nm_prec_var = 'prate'! name of variable in file with total precipitation
character(len=34), save :: nm_snow_var = 'snow' ! name of variable in file with snow precipitation
character(len=34), save :: nm_mslp_var = 'mslp' ! name of variable in file with mean sea level pressure
character(len=256), save :: nm_xwind_file = '/scratch/usr/hbkncara/input/forcing/historical/echam6_echam_' ! name of file with winds/stress, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_ywind_file = '/scratch/usr/hbkncara/input/forcing/historical/echam6_echam_' ! name of file with winds/stress, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_humi_file = '/scratch/usr/hbkncara/input/forcing/historical/echam6_echam_' ! name of file with humidity, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_qsr_file = '/scratch/usr/hbkncara/input/forcing/historical/echam6_echam_' ! name of file with solar heat, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_qlw_file = '/scratch/usr/hbkncara/input/forcing/historical/echam6_echam_' ! name of file with Long wave, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_tair_file = '/scratch/usr/hbkncara/input/forcing/historical/echam6_echam_' ! name of file with 2m air temperature, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_prec_file = '/scratch/usr/hbkncara/input/forcing/historical/echam6_echam_' ! name of file with total precipitation, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_snow_file = '/scratch/usr/hbkncara/input/forcing/historical/echam6_echam_' ! name of file with snow precipitation, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_mslp_file = '/scratch/usr/hbkncara/input/forcing/historical/echam6_echam_' ! name of file with mean sea level pressure, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model
character(len=256), save :: nm_cloud_file = '/scratch/usr/hbkncara/input/forcing/historical/echam6_echam_' ! name of file with clouds, if netcdf file then provide only name from "nameyyyy.nc" yyyy.nc will be added by model

character(len=34), save :: nm_xwind_var = 'u10' ! name of variable in file with wind
character(len=34), save :: nm_ywind_var = 'v10' ! name of variable in file with wind
character(len=34), save :: nm_humi_var = 'q2m' ! name of variable in file with humidity
character(len=34), save :: nm_qsr_var = 'DSWR'! name of variable in file with solar heat
character(len=34), save :: nm_qlw_var = 'DLWR'! name of variable in file with Long wave
character(len=34), save :: nm_tair_var = 'temp2' ! name of variable in file with 2m air temperature
character(len=34), save :: nm_prec_var = 'PREC'! name of variable in file with total precipitation
character(len=34), save :: nm_snow_var = 'aprs' ! name of variable in file with snow precipitation
character(len=34), save :: nm_mslp_var = 'aps' ! name of variable in file with mean sea level pressure
character(len=34), save :: nm_cloud_var = 'cloud'! name of variable in file with clouds

! ========== netCDF time param
integer, save :: nm_nc_iyear = 1948 ! initial year of time axis in netCDF (1948 like CoastDat,1800 NCEP)
integer, save :: nm_nc_iyear = 1850 ! initial year of time axis in netCDF (1948 like CoastDat,1800 NCEP)
integer, save :: nm_nc_imm = 1 ! initial month of time axis in netCDF
integer, save :: nm_nc_idd = 1 ! initial day of time axis in netCDF
real, save :: nm_nc_freq = 86400.0 ! time units coef (86400 CoastDat, 24 NCEP)
integer, save :: nm_nc_tmid = 1 ! 1 if the time stamps are given at the mid points of the netcdf file, 0 otherwise!
real, save :: nm_nc_freq = 1.0 ! time units coef (86400 CoastDat, 24 NCEP)
integer, save :: nm_nc_tmid = 0 ! 1 if the time stamps are given at the mid points of the netcdf file, 0 otherwise!
logical, save :: y_perpetual=.false.

integer,save :: warn ! warning switch node/element coordinate out of forcing bounds
Expand Down Expand Up @@ -477,16 +477,16 @@ SUBROUTINE nc_sbc_ini_fillnames(yyyy)
!! ** Purpose : Fill names of sbc_flfi array (file names and variable names)

!prepare proper nc file (add year and .nc to the end of the file name from namelist
if (l_xwind) write(sbc_flfi(i_xwind)%file_name, *) trim(nm_xwind_file),trim(yyear),'.nc'
if (l_ywind) write(sbc_flfi(i_ywind)%file_name, *) trim(nm_ywind_file),trim(yyear),'.nc'
if (l_humi) write(sbc_flfi(i_humi)%file_name, *) trim(nm_humi_file), trim(yyear),'.nc'
if (l_qsr) write(sbc_flfi(i_qsr)%file_name, *) trim(nm_qsr_file), trim(yyear),'.nc'
if (l_qlw) write(sbc_flfi(i_qlw)%file_name, *) trim(nm_qlw_file), trim(yyear),'.nc'
if (l_tair) write(sbc_flfi(i_tair)%file_name, *) trim(nm_tair_file), trim(yyear),'.nc'
if (l_prec) write(sbc_flfi(i_prec)%file_name, *) trim(nm_prec_file), trim(yyear),'.nc'
if (l_snow) write(sbc_flfi(i_snow)%file_name, *) trim(nm_snow_file), trim(yyear),'.nc'
if (l_mslp) write(sbc_flfi(i_mslp)%file_name, *) trim(nm_mslp_file), trim(yyear),'.nc'
if (l_cloud) write(sbc_flfi(i_cloud)%file_name, *) trim(nm_cloud_file),trim(yyear),'.nc'
if (l_xwind) write(sbc_flfi(i_xwind)%file_name, *) trim(nm_xwind_file),trim(yyear),'01_reduced.nc'
if (l_ywind) write(sbc_flfi(i_ywind)%file_name, *) trim(nm_ywind_file),trim(yyear),'01_reduced.nc'
if (l_humi) write(sbc_flfi(i_humi)%file_name, *) trim(nm_humi_file), trim(yyear),'01_reduced.nc'
if (l_qsr) write(sbc_flfi(i_qsr)%file_name, *) trim(nm_qsr_file), trim(yyear),'01_reduced.nc'
if (l_qlw) write(sbc_flfi(i_qlw)%file_name, *) trim(nm_qlw_file), trim(yyear),'01_reduced.nc'
if (l_tair) write(sbc_flfi(i_tair)%file_name, *) trim(nm_tair_file), trim(yyear),'01_reduced.nc'
if (l_prec) write(sbc_flfi(i_prec)%file_name, *) trim(nm_prec_file), trim(yyear),'01_reduced.nc'
if (l_snow) write(sbc_flfi(i_snow)%file_name, *) trim(nm_snow_file), trim(yyear),'01_reduced.nc'
if (l_mslp) write(sbc_flfi(i_mslp)%file_name, *) trim(nm_mslp_file), trim(yyear),'01_reduced.nc'
if (l_cloud) write(sbc_flfi(i_cloud)%file_name, *) trim(nm_cloud_file),trim(yyear),'01_reduced.nc'

if (l_xwind) sbc_flfi(i_xwind)%file_name=ADJUSTL(trim(sbc_flfi(i_xwind)%file_name))
if (l_ywind) sbc_flfi(i_ywind)%file_name=ADJUSTL(trim(sbc_flfi(i_ywind)%file_name))
Expand Down Expand Up @@ -1052,6 +1052,7 @@ SUBROUTINE sbc_do(mesh)
real(wp) :: rdate ! date
integer :: fld_idx, i
logical :: do_rotation, force_newcoeff, update_monthly_flag
logical :: update_daily_flag ! CN: for river runoff from AWICM
integer :: yyyy, dd, mm
integer, pointer :: nc_Ntime, t_indx, t_indx_p1
real(wp), pointer :: nc_time(:)
Expand Down Expand Up @@ -1102,7 +1103,8 @@ SUBROUTINE sbc_do(mesh)
! prepare a flag which checks whether to update monthly data (SSS, river runoff)
!update_monthly_flag=((day_in_month==num_day_in_month(fleapyear,month) .and. timenew==86400._WP))
update_monthly_flag=( (day_in_month==num_day_in_month(fleapyear,month) .AND. timenew==86400._WP) .OR. mstep==1 )

! CN: same for daily forcing (river runoff from AWICM)
update_daily_flag = ( (timenew==86400._WP) .OR. mstep==1 )

! read in SSS for applying SSS restoring
if (surf_relax_S > 0._WP) then
Expand Down Expand Up @@ -1154,6 +1156,17 @@ SUBROUTINE sbc_do(mesh)

end if

!CN: AWICM runoff
if(runoff_data_source=='AWICM') then
if(update_daily_flag) then
! daily data (already in m/s)
i=daynew
filename=trim(nm_runoff_file)//cyearnew//'0101_redistributed.nc' !runoff_fesom_19630101_redistributed.nc
!if (mype==0) write(*,*) filename
call read_2ddata_on_grid_NetCDF(filename,'runoff', i, runoff, mesh)
!if (mype==0) write(*,*) 'Day ',i,', runoff: min=', minval(runoff),';max=',maxval(runoff)
endif
endif

! interpolate in time
call data_timeinterp(rdate)
Expand Down
Loading

0 comments on commit daa02d4

Please sign in to comment.