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

Add support for JRA55do #843

Merged
merged 15 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
207 changes: 110 additions & 97 deletions cicecore/cicedyn/general/ice_forcing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module ice_forcing
fyear_final ! last year in cycle, computed at init

character (char_len_long) :: & ! input data file names
uwind_file, &
uwind_file, & ! this is also used a generic file containing all fields for JRA55
vwind_file, &
wind_file, &
strax_file, &
Expand Down Expand Up @@ -124,7 +124,7 @@ module ice_forcing
ocn_data_format, & ! 'bin'=binary or 'nc'=netcdf
atm_data_type, & ! 'default', 'monthly', 'ncar', 'box2001'
! 'hadgem', 'oned', 'calm', 'uniform'
! 'JRA55_gx1' or 'JRA55_gx3' or 'JRA55_tx1'
! 'JRA55' or 'JRA55do'
bgc_data_type, & ! 'default', 'clim'
ocn_data_type, & ! 'default', 'clim', 'ncar', 'oned', 'calm', 'box2001'
! 'hadgem_sst' or 'hadgem_sst_uvocn', 'uniform'
Expand Down Expand Up @@ -281,13 +281,11 @@ subroutine init_forcing_atmo
file=__FILE__, line=__LINE__)
endif

if (use_leap_years .and. (trim(atm_data_type) /= 'JRA55_gx1' .and. &
trim(atm_data_type) /= 'JRA55_gx3' .and. &
trim(atm_data_type) /= 'JRA55_tx1' .and. &
trim(atm_data_type) /= 'hycom' .and. &
trim(atm_data_type) /= 'box2001')) then
if (use_leap_years .and. (index(trim(atm_data_type),'JRA55') == 0 .and. &
trim(atm_data_type) /= 'hycom' .and. &
trim(atm_data_type) /= 'box2001')) then
write(nu_diag,*) 'use_leap_years option is currently only supported for'
write(nu_diag,*) 'JRA55, default , and box2001 atmospheric data'
write(nu_diag,*) 'JRA55, JRA55do, default , and box2001 atmospheric data'
call abort_ice(error_message=subname, file=__FILE__, line=__LINE__)
endif

Expand All @@ -298,12 +296,8 @@ subroutine init_forcing_atmo
! default forcing values from init_flux_atm
if (trim(atm_data_type) == 'ncar') then
call NCAR_files(fyear)
elseif (trim(atm_data_type) == 'JRA55_gx1') then
call JRA55_gx1_files(fyear)
elseif (trim(atm_data_type) == 'JRA55_gx3') then
call JRA55_gx3_files(fyear)
elseif (trim(atm_data_type) == 'JRA55_tx1') then
call JRA55_tx1_files(fyear)
elseif (index(trim(atm_data_type),'JRA55') > 0) then
call JRA55_files(fyear)
elseif (trim(atm_data_type) == 'hadgem') then
call hadgem_files(fyear)
elseif (trim(atm_data_type) == 'monthly') then
Expand Down Expand Up @@ -640,11 +634,7 @@ subroutine get_forcing_atmo

if (trim(atm_data_type) == 'ncar') then
call ncar_data
elseif (trim(atm_data_type) == 'JRA55_gx1') then
call JRA55_data
elseif (trim(atm_data_type) == 'JRA55_gx3') then
call JRA55_data
elseif (trim(atm_data_type) == 'JRA55_tx1') then
elseif (index(trim(atm_data_type),'JRA55') > 0) then
call JRA55_data
elseif (trim(atm_data_type) == 'hadgem') then
call hadgem_data
Expand Down Expand Up @@ -1585,15 +1575,7 @@ subroutine file_year (data_file, yr)
i = index(data_file,'.nc') - 5
tmpname = data_file
write(data_file,'(a,i4.4,a)') tmpname(1:i), yr, '.nc'
elseif (trim(atm_data_type) == 'JRA55_gx1') then ! netcdf
i = index(data_file,'.nc') - 5
tmpname = data_file
write(data_file,'(a,i4.4,a)') tmpname(1:i), yr, '.nc'
elseif (trim(atm_data_type) == 'JRA55_gx3') then ! netcdf
i = index(data_file,'.nc') - 5
tmpname = data_file
write(data_file,'(a,i4.4,a)') tmpname(1:i), yr, '.nc'
elseif (trim(atm_data_type) == 'JRA55_tx1') then ! netcdf
elseif (index(trim(atm_data_type),'JRA55') > 0) then ! netcdf
i = index(data_file,'.nc') - 5
tmpname = data_file
write(data_file,'(a,i4.4,a)') tmpname(1:i), yr, '.nc'
Expand Down Expand Up @@ -1956,58 +1938,63 @@ subroutine ncar_files (yr)
! Edit for other directory structures or filenames.
! Note: The year number in these filenames does not matter, because
! subroutine file_year will insert the correct year.
! Note: atm_data_dir may have NCAR_bulk or not

integer (kind=int_kind), intent(in) :: &
yr ! current forcing year

character (char_len_long) :: &
atm_data_dir_extra ! atm_dat_dir extra if needed

integer (kind=int_kind) :: &
strind ! string index

character(len=*), parameter :: subname = '(ncar_files)'

if (local_debug .and. my_task == master_task) write(nu_diag,*) subname,'fdbg start'

fsw_file = &
trim(atm_data_dir)//'/MONTHLY/swdn.1996.dat'
atm_data_dir_extra = '/NCAR_bulk'
strind = index(trim(atm_data_dir),'NCAR_bulk')
if (strind > 0) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment that atm_data_dir_extra accounts for differences in the data directory structure for different data sets, for backwards compatibility

atm_data_dir_extra = ''
endif

fsw_file = trim(atm_data_dir)//trim(atm_data_dir_extra)//'/MONTHLY/swdn.1996.dat'
call file_year(fsw_file,yr)

flw_file = &
trim(atm_data_dir)//'/MONTHLY/cldf.1996.dat'
flw_file = trim(atm_data_dir)//trim(atm_data_dir_extra)//'/MONTHLY/cldf.1996.dat'
call file_year(flw_file,yr)

rain_file = &
trim(atm_data_dir)//'/MONTHLY/prec.1996.dat'
rain_file = trim(atm_data_dir)//trim(atm_data_dir_extra)//'/MONTHLY/prec.1996.dat'
call file_year(rain_file,yr)

uwind_file = &
trim(atm_data_dir)//'/4XDAILY/u_10.1996.dat'
uwind_file = trim(atm_data_dir)//trim(atm_data_dir_extra)//'/4XDAILY/u_10.1996.dat'
call file_year(uwind_file,yr)

vwind_file = &
trim(atm_data_dir)//'/4XDAILY/v_10.1996.dat'
vwind_file = trim(atm_data_dir)//trim(atm_data_dir_extra)//'/4XDAILY/v_10.1996.dat'
call file_year(vwind_file,yr)

tair_file = &
trim(atm_data_dir)//'/4XDAILY/t_10.1996.dat'
tair_file = trim(atm_data_dir)//trim(atm_data_dir_extra)//'/4XDAILY/t_10.1996.dat'
call file_year(tair_file,yr)

humid_file = &
trim(atm_data_dir)//'/4XDAILY/q_10.1996.dat'
humid_file = trim(atm_data_dir)//trim(atm_data_dir_extra)//'/4XDAILY/q_10.1996.dat'
call file_year(humid_file,yr)

rhoa_file = &
trim(atm_data_dir)//'/4XDAILY/dn10.1996.dat'
rhoa_file = trim(atm_data_dir)//trim(atm_data_dir_extra)//'/4XDAILY/dn10.1996.dat'
call file_year(rhoa_file,yr)

if (my_task == master_task) then
write (nu_diag,*) ' '
write (nu_diag,*) 'Forcing data year =', fyear
write (nu_diag,*) 'Atmospheric data files:'
write (nu_diag,*) trim(fsw_file)
write (nu_diag,*) trim(flw_file)
write (nu_diag,*) trim(rain_file)
write (nu_diag,*) trim(uwind_file)
write (nu_diag,*) trim(vwind_file)
write (nu_diag,*) trim(tair_file)
write (nu_diag,*) trim(humid_file)
write (nu_diag,*) trim(rhoa_file)
write (nu_diag,'(3a)') trim(fsw_file)
write (nu_diag,'(3a)') trim(flw_file)
write (nu_diag,'(3a)') trim(rain_file)
write (nu_diag,'(3a)') trim(uwind_file)
write (nu_diag,'(3a)') trim(vwind_file)
write (nu_diag,'(3a)') trim(tair_file)
write (nu_diag,'(3a)') trim(humid_file)
write (nu_diag,'(3a)') trim(rhoa_file)
endif ! master_task

end subroutine ncar_files
Expand Down Expand Up @@ -2172,66 +2159,92 @@ end subroutine ncar_data

!=======================================================================

subroutine JRA55_gx1_files(yr)
!
subroutine JRA55_files(yr)

! find the JRA55 files:
! atm_data_type could be JRA55 or JRA55do with/without _grid appended
! atm_data_dir could contain JRA55 or JRA55do or not
! actual files could have grid in name in two location or not at all

integer (kind=int_kind), intent(in) :: &
yr ! current forcing year
yr ! current forcing year

character(len=*), parameter :: subname = '(JRA55_gx1_files)'
! local variables
character(len=16) :: &
grd ! gx3, gx1, tx1

character(len=64) :: &
atm_data_type_prefix ! atm_data_type prefix

integer (kind=int_kind) :: &
cnt , & ! search for file
strind ! string index

logical :: &
exists ! file existance

character(len=*), parameter :: subname = '(JRA55_files)'

if (local_debug .and. my_task == master_task) write(nu_diag,*) subname,'fdbg start'

uwind_file = &
trim(atm_data_dir)//'/8XDAILY/JRA55_03hr_forcing_2005.nc'
call file_year(uwind_file,yr)
if (my_task == master_task) then
write (nu_diag,*) ' '
write (nu_diag,*) 'Atmospheric data files:'
write (nu_diag,*) trim(uwind_file)
! this could be JRA55[do] or JRA55[do]_grid, drop the _grid if set
atm_data_type_prefix = trim(atm_data_type)
strind = index(trim(atm_data_type),'_')
if (strind > 0) then
atm_data_type_prefix = atm_data_type(1:strind-1)
endif
end subroutine JRA55_gx1_files

!=======================================================================
! check for grid version using fortran INDEX intrinsic
if (index(trim(atm_data_dir),'gx1') > 0) then
grd = 'gx1'
else if (index(trim(atm_data_dir),'gx3') > 0) then
grd = 'gx3'
else if (index(trim(atm_data_dir),'tx1') > 0) then
grd = 'tx1'
else
call abort_ice(error_message=subname//' unknown grid type')
endif

subroutine JRA55_tx1_files(yr)
!
integer (kind=int_kind), intent(in) :: &
yr ! current forcing year
exists = .false.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: ! checks whether the needed data file path/name has already been created at a previous time step (or whatever)

cnt = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: ! steps through each of the 6 forcing fields in the data set

do while (.not.exists .and. cnt <= 6)
if (cnt == 1) uwind_file = trim(atm_data_dir)//'/'//trim(atm_data_type_prefix)// &
'/8XDAILY/'//trim(atm_data_type_prefix)//'_'//trim(grd)//'_03hr_forcing_2005.nc'

character(len=*), parameter :: subname = '(JRA55_tx1_files)'
if (cnt == 2) uwind_file = trim(atm_data_dir)//'/'//trim(atm_data_type_prefix)// &
'/8XDAILY/'//trim(atm_data_type_prefix)//'_03hr_forcing_'//trim(grd)//'_2005.nc'

if (local_debug .and. my_task == master_task) write(nu_diag,*) subname,'fdbg start'
if (cnt == 3) uwind_file = trim(atm_data_dir)//'/'//trim(atm_data_type_prefix)// &
'/8XDAILY/'//trim(atm_data_type_prefix)// '_03hr_forcing_2005.nc'

uwind_file = &
trim(atm_data_dir)//'/8XDAILY/JRA55_03hr_forcing_tx1_2005.nc'
call file_year(uwind_file,yr)
if (my_task == master_task) then
write (nu_diag,*) ' '
write (nu_diag,*) 'Atmospheric data files:'
write (nu_diag,*) trim(uwind_file)
endif
end subroutine JRA55_tx1_files
if (cnt == 4) uwind_file = trim(atm_data_dir)// &
'/8XDAILY/'//trim(atm_data_type_prefix)//'_'//trim(grd)//'_03hr_forcing_2005.nc'

!=======================================================================
if (cnt == 5) uwind_file = trim(atm_data_dir)// &
'/8XDAILY/'//trim(atm_data_type_prefix)//'_03hr_forcing_'//trim(grd)//'_2005.nc'

subroutine JRA55_gx3_files(yr)
!
integer (kind=int_kind), intent(in) :: &
yr ! current forcing year
if (cnt == 6) uwind_file = trim(atm_data_dir)// &
'/8XDAILY/'//trim(atm_data_type_prefix)// '_03hr_forcing_2005.nc'

character(len=*), parameter :: subname = '(JRA55_gx3_files)'
call file_year(uwind_file,yr)
INQUIRE(FILE=uwind_file,EXIST=exists)
! if (my_task == master_task) then
! write(nu_diag,*) subname,cnt,exists,trim(uwind_file)
! endif
cnt = cnt + 1
enddo

if (local_debug .and. my_task == master_task) write(nu_diag,*) subname,'fdbg start'
if (.not.exists) then
call abort_ice(error_message=subname//' could not find forcing file')
endif

uwind_file = &
trim(atm_data_dir)//'/8XDAILY/JRA55_gx3_03hr_forcing_2005.nc'
call file_year(uwind_file,yr)
if (my_task == master_task) then
write (nu_diag,*) ' '
write (nu_diag,*) 'Atmospheric data files:'
write (nu_diag,*) trim(uwind_file)
write (nu_diag,'(2a)') ' '
write (nu_diag,'(2a)') subname,'Atmospheric data files:'
write (nu_diag,'(2a)') subname,trim(uwind_file)
endif
end subroutine JRA55_gx3_files

end subroutine JRA55_files

!=======================================================================

Expand Down Expand Up @@ -2303,7 +2316,7 @@ subroutine JRA55_data

uwind_file_old = uwind_file
if (uwind_file /= uwind_file_old .and. my_task == master_task) then
write(nu_diag,*) subname,' reading forcing file = ',trim(uwind_file)
write(nu_diag,'(2a)') subname,' reading forcing file = ',trim(uwind_file)
endif

call ice_open_nc(uwind_file,ncid)
Expand All @@ -2315,7 +2328,7 @@ subroutine JRA55_data
if (n1 == 1) then
recnum = 8*int(yday) - 7 + int(real(msec,kind=dbl_kind)/sec3hr)
if (my_task == master_task .and. (recnum <= 2 .or. recnum >= maxrec-1)) then
write(nu_diag,*) subname,' reading forcing file 1st ts = ',trim(uwind_file)
write(nu_diag,'(3a)') subname,' reading forcing file 1st ts = ',trim(uwind_file)
endif
elseif (n1 == 2) then
recnum = 8*int(yday) - 7 + int(real(msec,kind=dbl_kind)/sec3hr) + 1
Expand All @@ -2325,7 +2338,7 @@ subroutine JRA55_data
recnum = 1
call file_year(uwind_file,lfyear)
if (my_task == master_task) then
write(nu_diag,*) subname,' reading forcing file 2nd ts = ',trim(uwind_file)
write(nu_diag,'(3a)') subname,' reading forcing file 2nd ts = ',trim(uwind_file)
endif
call ice_close_nc(ncid)
call ice_open_nc(uwind_file,ncid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ subroutine ice_write_hist (ns)
!-----------------------------------------------------------------
! write time variable
!-----------------------------------------------------------------

ltime2 = timesecs/secday ! hist_time_axis = 'end' (default)

! Some coupled models require the time axis "stamp" to be in the middle
Expand All @@ -762,7 +762,7 @@ subroutine ice_write_hist (ns)
if (trim(hist_time_axis) == "begin" ) ltime2 = time_beg(ns)
if (trim(hist_time_axis) == "middle") ltime2 = p5*(time_beg(ns)+time_end(ns))
endif

status = nf90_inq_varid(ncid,'time',varid)
if (status /= nf90_noerr) call abort_ice(subname// &
'ERROR: getting time varid')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ subroutine ice_write_hist (ns)
if (trim(hist_time_axis) == "begin" ) ltime2 = time_beg(ns)
if (trim(hist_time_axis) == "middle") ltime2 = p5*(time_beg(ns)+time_end(ns))
endif

status = pio_inq_varid(File,'time',varid)
status = pio_put_var(File,varid,(/1/),ltime2)

Expand Down
4 changes: 2 additions & 2 deletions configuration/scripts/machines/Macros.onyx_intel
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

CPP := fpp
CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS}
CFLAGS := -c -O2 -fp-model precise -xHost
CFLAGS := -c -O2 -fp-model precise

FIXEDFLAGS := -132
FREEFLAGS := -FR
FFLAGS := -fp-model precise -convert big_endian -assume byterecl -ftz -traceback -xHost
FFLAGS := -fp-model precise -convert big_endian -assume byterecl -ftz -traceback
FFLAGS_NOOPT:= -O0

ifeq ($(ICE_BLDDEBUG), true)
Expand Down
10 changes: 5 additions & 5 deletions configuration/scripts/machines/env.nrlssc_gnu
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ setenv ICE_MACHINE_MACHINFO "nrlssc"
setenv ICE_MACHINE_ENVNAME gnu
setenv ICE_MACHINE_ENVINFO "gnu"
setenv ICE_MACHINE_MAKE gmake
setenv ICE_MACHINE_WKDIR /u/data/hebert/CICE_RUNS
setenv ICE_MACHINE_INPUTDATA /u/data/hebert/CICE_RUNS
setenv ICE_MACHINE_BASELINE /u/data/hebert/CICE_BASELINE
setenv ICE_MACHINE_WKDIR /u/hebert/data/CICE_RUNS
setenv ICE_MACHINE_INPUTDATA /u/hebert/data/
setenv ICE_MACHINE_BASELINE /u/hebert/data/CICE_BASELINE
setenv ICE_MACHINE_SUBMIT "qsub "
setenv ICE_MACHINE_ACCT P00000000
setenv ICE_MACHINE_QUEUE "standard"
setenv ICE_MACHINE_TPNODE 20 # tasks per node
setenv ICE_MACHINE_BLDTHRDS 1
setenv ICE_MACHINE_TPNODE 28 # tasks per node
setenv ICE_MACHINE_BLDTHRDS 8
setenv ICE_MACHINE_QSTAT "qstat "
Loading
Loading