Skip to content

Commit 4d482fe

Browse files
committed
ERA5 test working - still need to deal with JRA55 vs ERA NetCDF time units (days -> hours)
1 parent 8ba55e7 commit 4d482fe

File tree

9 files changed

+52
-49
lines changed

9 files changed

+52
-49
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,10 @@ cd libaccessom2
8282
First do build as above. Then to get some computer resources:
8383

8484
```{bash}
85-
qsub -I -P x77 -q normal -lncpus=4 -lmem=16Gb -lwalltime=3:00:00 -lstorage=gdata/ua8+gdata/qv56+gdata/hh5+gdata/ik11
86-
87-
/g/data1b/qv56/
85+
qsub -I -P x77 -q normal -lncpus=4 -lmem=16Gb -lwalltime=3:00:00 -lstorage=gdata/ua8+gdata/qv56+gdata/hh5+gdata/ik11+gdata/v45+gdata/rt52
8886
```
8987

90-
The tests: `JRA55_IAF JRA55_IAF_SINGLE_FIELD JRA55_RYF JRA55_RYF_MINIMAL JRA55_v1p4_IAF` can all be run manually as follows. Replace `JRA55_IAF` with the test to be run.
88+
The tests: `JRA55_IAF JRA55_IAF_SINGLE_FIELD JRA55_RYF JRA55_RYF_MINIMAL JRA55_v1p4_IAF ERA5` can all be run manually as follows. Replace `JRA55_IAF` with the test to be run.
9189

9290
```{bash}
9391
export LIBACCESSOM2_ROOT=$(pwd)

libforcing/src/forcing_config.F90

+2
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ subroutine forcing_config_parse_input(self, input_jv_ptr, field_ptr, &
168168
call self%core%get_child(input_jv_ptr, "input_fields", &
169169
input_field_jv_list, found)
170170
num_input_fields = self%core%count(input_field_jv_list)
171+
allocate(filename_list(num_input_fields), fieldname_list(num_input_fields))
172+
171173
do i=1, num_input_fields
172174
call self%core%get_child(input_field_jv_list, i, &
173175
input_field_jv_ptr, found)

libforcing/src/ncvar.F90

+16-13
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ subroutine ncvar_refresh(self, filename, &
120120
call ncheck(nf90_get_var(self%ncid, time_varid, self%times), &
121121
'ncvar get_var time in: '//trim(self%filename))
122122

123-
self%dt = int((self%times(2) - self%times(1))*86400)
123+
self%dt = int((self%times(2) - self%times(1))*3600)
124124
! Initialise start date and calendar
125125
call self%get_start_date_and_calendar(time_varid, self%start_date, self%calendar)
126126

@@ -170,12 +170,15 @@ subroutine get_start_date_and_calendar(self, time_varid, start_date, calendar)
170170
call ncheck(nf90_get_att(self%ncid, time_varid, "units", time_str), &
171171
'get_start_date_and_calendar: nf90_get_att: '//time_str)
172172

173-
174173
! See whether it has the expected format
175174
idx = index(trim(time_str), "days since")
175+
time_str = replace_text(time_str, "days since ", "")
176+
if (idx <= 0) then
177+
idx = index(trim(time_str), "hours since")
178+
time_str = replace_text(time_str, "hours since ", "")
179+
endif
176180
call assert(idx > 0, "ncvar invalid time format")
177181

178-
time_str = replace_text(time_str, "days since ", "")
179182
! See whether we have hours
180183
idx = index(time_str, ":")
181184
if (idx > 0) then
@@ -196,7 +199,7 @@ function get_index_for_datetime(self, target_date, from_beginning, guess)
196199
integer, optional, intent(in) :: guess
197200

198201
integer :: i, get_index_for_datetime
199-
integer :: days, seconds
202+
integer :: days, hours, seconds
200203

201204
type(timedelta) :: td, td_before, td_after
202205

@@ -214,13 +217,13 @@ function get_index_for_datetime(self, target_date, from_beginning, guess)
214217
do i=self%idx_guess, size(self%time_bnds, 2)
215218
! Must convert to days _and_ seconds rather than just days to avoid
216219
! integer overflow.
217-
days = floor(self%time_bnds(1, i))
218-
seconds = nint((self%time_bnds(1, i) - days)*86400)
219-
td_before = timedelta(days=days, seconds=seconds)
220+
hours = floor(self%time_bnds(1, i))
221+
seconds = nint((self%time_bnds(1, i) - hours)*3600)
222+
td_before = timedelta(hours=hours, seconds=seconds)
220223

221-
days = floor(self%time_bnds(2, i))
222-
seconds = nint((self%time_bnds(2, i) - days)*86400)
223-
td_after = timedelta(days=days, seconds=seconds)
224+
hours = floor(self%time_bnds(2, i))
225+
seconds = nint((self%time_bnds(2, i) - hours)*3600)
226+
td_after = timedelta(hours=hours, seconds=seconds)
224227

225228
if (target_date >= (self%start_date + td_before) .and. &
226229
target_date < (self%start_date + td_after)) then
@@ -231,9 +234,9 @@ function get_index_for_datetime(self, target_date, from_beginning, guess)
231234
enddo
232235
else
233236
do i=self%idx_guess, size(self%times)
234-
days = floor(self%times(i))
235-
seconds = nint((self%times(i) - days)*86400)
236-
td = timedelta(days=days, seconds=seconds)
237+
hours = floor(self%times(i))
238+
seconds = nint((self%times(i) - hours)*3600)
239+
td = timedelta(hours=hours, seconds=seconds)
237240

238241
if (target_date == (self%start_date + td)) then
239242
get_index_for_datetime = i

libforcing/src/util.F90

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ function filename_for_date(filename_template, date)
190190

191191
start_day = 1
192192
end_day = DAYS_IN_MONTH(month)
193-
write(start_day_str, "(I2)") start_day
194-
write(end_day_str, "(I2)") end_day
193+
write(start_day_str, "(I2.2)") start_day
194+
write(end_day_str, "(I2.2)") end_day
195195

196196
filename_for_date = replace_text(filename_template, &
197197
"{{ year }}", year_str)

tests/ERA5/accessom2.nml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
&accessom2_nml
22
log_level = 'DEBUG'
3-
ice_ocean_timestep = 5400
3+
ice_ocean_timestep = 3600
44
enable_simple_timers = .true.
55
/
66

77
&date_manager_nml
8-
forcing_start_date = '1958-12-30T00:00:00'
9-
forcing_end_date = '1960-01-01T00:00:00'
8+
forcing_start_date = '1980-12-30T00:00:00'
9+
forcing_end_date = '2020-01-01T00:00:00'
1010
restart_period = 1, 0, 0
1111
/

tests/ERA5/forcing.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"coupling_field_name": "tair_ai",
7575
"input_fields": [
7676
{
77-
"filename": "/g/data/rt52/era5/single-levels/reanalysis/t2m/{{year}}/t2m_era5_oper_sfc_{{year}}{{month}}{{start_day}}-{{year}}{{month}}{{end_day}}.nc",
77+
"filename": "/g/data/rt52/era5/single-levels/reanalysis/2t/{{year}}/2t_era5_oper_sfc_{{year}}{{month}}{{start_day}}-{{year}}{{month}}{{end_day}}.nc",
7878
"fieldname": "t2m"
7979
}
8080
]
@@ -83,11 +83,11 @@
8383
"coupling_field_name": "qair_ai",
8484
"input_fields": [
8585
{
86-
"filename": "/g/data/rt52/era5/single-levels/reanalysis/t2m/{{year}}/t2m_era5_oper_sfc_{{year}}{{month}}{{start_day}}-{{year}}{{month}}{{end_day}}.nc",
86+
"filename": "/g/data/rt52/era5/single-levels/reanalysis/2t/{{year}}/2t_era5_oper_sfc_{{year}}{{month}}{{start_day}}-{{year}}{{month}}{{end_day}}.nc",
8787
"fieldname": "t2m"
8888
},
8989
{
90-
"filename": "/g/data/rt52/era5/single-levels/reanalysis/d2m/{{year}}/d2m_era5_oper_sfc_{{year}}{{month}}{{start_day}}-{{year}}{{month}}{{end_day}}.nc",
90+
"filename": "/g/data/rt52/era5/single-levels/reanalysis/2d/{{year}}/2d_era5_oper_sfc_{{year}}{{month}}{{start_day}}-{{year}}{{month}}{{end_day}}.nc",
9191
"fieldname": "d2m"
9292
}
9393
]
@@ -96,7 +96,7 @@
9696
"coupling_field_name": "uwnd_ai",
9797
"input_fields": [
9898
{
99-
"filename": "/g/data/rt52/era5/single-levels/reanalysis/u10/{{year}}/u10_era5_oper_sfc_{{year}}{{month}}{{start_day}}-{{year}}{{month}}{{end_day}}.nc",
99+
"filename": "/g/data/rt52/era5/single-levels/reanalysis/10u/{{year}}/10u_era5_oper_sfc_{{year}}{{month}}{{start_day}}-{{year}}{{month}}{{end_day}}.nc",
100100
"fieldname": "u10"
101101
}
102102
]
@@ -105,7 +105,7 @@
105105
"coupling_field_name": "vwnd_ai",
106106
"input_fields": [
107107
{
108-
"filename": "/g/data/rt52/era5/single-levels/reanalysis/v10/{{year}}/v10_era5_oper_sfc_{{year}}{{month}}{{start_day}}-{{year}}{{month}}{{end_day}}.nc",
108+
"filename": "/g/data/rt52/era5/single-levels/reanalysis/10v/{{year}}/10v_era5_oper_sfc_{{year}}{{month}}{{start_day}}-{{year}}{{month}}{{end_day}}.nc",
109109
"fieldname": "v10"
110110
}
111111
]

tests/ERA5/ice.nml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
from_ocean_field_names = 'sst_i', 'sss_i', 'ssu_i', 'ssv_i', 'sslx_i', 'ssly_i', 'pfmice_i'
66
ice_grid_file = '../test_data/grid.nc'
77
ice_mask_file = '../test_data/kmt.nc'
8-
dt = 5400
8+
dt = 3600
99
&end

tests/ERA5/namcouple

+20-20
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# This gives you the total simulated time for this run in seconds
3232
# This is not used but needs to be >= to the timestep to satisfy error checking.
3333
# See https://github.com/COSIMA/oasis3-mct/issues/3
34-
10800
34+
3600
3535
$END
3636
###########################################################################
3737
$NLOGPRT
@@ -51,62 +51,62 @@
5151
##########
5252
# Field 01 : swflx down
5353
##########
54-
swfld_ai swfld_i 367 10800 3 a2i.nc EXPORTED
54+
swfld_ai swfld_i 367 3600 3 a2i.nc EXPORTED
5555
jrat cict LAG=0 SEQ=+1
5656
P 0 P 0
5757
#
5858
LOCTRANS MAPPING SCRIPR
5959
INSTANT
60-
../test_data/rmp_jra55_cice_1st_conserve.nc dst
60+
../test_data/ERA5_MOM1_conserve.nc dst
6161
CONSERV LR SCALAR LATLON 10 FRACNNEI FIRST
6262
#########
6363
# Field 02 : lwflx down
6464
##########
65-
lwfld_ai lwfld_i 366 10800 3 a2i.nc EXPORTED
65+
lwfld_ai lwfld_i 366 3600 3 a2i.nc EXPORTED
6666
jrat cict LAG=0 SEQ=+1
6767
P 0 P 0
6868
#
6969
LOCTRANS MAPPING SCRIPR
7070
INSTANT
71-
../test_data/rmp_jra55_cice_1st_conserve.nc dst
71+
../test_data/ERA5_MOM1_conserve.nc dst
7272
CONSERV LR SCALAR LATLON 10 FRACNNEI FIRST
7373
##########
7474
# Field 03 : rainfall
7575
##########
76-
rain_ai rain_i 26 10800 3 a2i.nc EXPORTED
76+
rain_ai rain_i 26 3600 3 a2i.nc EXPORTED
7777
jrat cict LAG=0 SEQ=+1
7878
P 0 P 0
7979
#
8080
LOCTRANS MAPPING SCRIPR
8181
INSTANT
82-
../test_data/rmp_jra55_cice_1st_conserve.nc dst
82+
../test_data/ERA5_MOM1_conserve.nc dst
8383
CONSERV LR SCALAR LATLON 10 FRACNNEI FIRST
8484
##########
8585
# Field 04 : snowfall
8686
##########
87-
snow_ai snow_i 26 10800 3 a2i.nc EXPORTED
87+
snow_ai snow_i 26 3600 3 a2i.nc EXPORTED
8888
jrat cict LAG=0 SEQ=+1
8989
P 0 P 0
9090
#
9191
LOCTRANS MAPPING SCRIPR
9292
INSTANT
93-
../test_data/rmp_jra55_cice_1st_conserve.nc dst
93+
../test_data/ERA5_MOM1_conserve.nc dst
9494
CONSERV LR SCALAR LATLON 10 FRACNNEI FIRST
9595
##########
9696
# Field 05 : surface pressure
9797
##########
98-
press_ai press_i 33 10800 3 a2i.nc EXPORTED
98+
press_ai press_i 33 3600 3 a2i.nc EXPORTED
9999
jrat cict LAG=0 SEQ=+1
100100
P 0 P 0
101101
#
102102
LOCTRANS MAPPING SCRIPR
103103
INSTANT
104-
../test_data/rmp_jra55_cice_patch.nc dst
104+
../test_data/ERA5_MOM1_patch.nc dst
105105
CONSERV LR SCALAR LATLON 10 FRACNNEI FIRST
106106
##########
107107
# Field 06 : runoff. Runoff is passed on the destination grid.
108108
##########
109-
runof_ai runof_i 297 10800 1 a2i.nc EXPORTED
109+
runof_ai runof_i 297 3600 1 a2i.nc EXPORTED
110110
cict cict LAG=0 SEQ=+1
111111
P 0 P 0
112112
#
@@ -115,44 +115,44 @@ INSTANT
115115
##########
116116
# Field 07 : near surface (2m) air temp
117117
##########
118-
tair_ai tair_i 110 10800 3 a2i.nc EXPORTED
118+
tair_ai tair_i 110 3600 3 a2i.nc EXPORTED
119119
jrat cict LAG=0 SEQ=+1
120120
P 0 P 0
121121
#
122122
LOCTRANS MAPPING SCRIPR
123123
INSTANT
124-
../test_data/rmp_jra55_cice_patch.nc dst
124+
../test_data/ERA5_MOM1_patch.nc dst
125125
CONSERV LR SCALAR LATLON 10 FRACNNEI FIRST
126126
##########
127127
# Field 08 : 2m air humidity
128128
##########
129-
qair_ai qair_i 339 10800 3 a2i.nc EXPORTED
129+
qair_ai qair_i 339 3600 3 a2i.nc EXPORTED
130130
jrat cict LAG=0 SEQ=+1
131131
P 0 P 0
132132
#
133133
LOCTRANS MAPPING SCRIPR
134134
INSTANT
135-
../test_data/rmp_jra55_cice_patch.nc dst
135+
../test_data/ERA5_MOM1_patch.nc dst
136136
CONSERV LR SCALAR LATLON 10 FRACNNEI FIRST
137137
##########
138138
# Field 09 : 10m wind (u)
139139
##########
140-
uwnd_ai uwnd_i 56 10800 2 a2i.nc EXPORTED
140+
uwnd_ai uwnd_i 56 3600 2 a2i.nc EXPORTED
141141
jrat cict LAG=0 SEQ=+1
142142
P 0 P 0
143143
#
144144
MAPPING SCRIPR
145-
../test_data/rmp_jra55_cice_patch.nc dst
145+
../test_data/ERA5_MOM1_patch.nc dst
146146
DISTWGT LR VECTOR LATLON 10 4 vwnd_ai
147147
##########
148148
# Field 10 : 10m wind (v)
149149
##########
150-
vwnd_ai vwnd_i 56 10800 2 a2i.nc EXPORTED
150+
vwnd_ai vwnd_i 56 3600 2 a2i.nc EXPORTED
151151
jrat cict LAG=0 SEQ=+1
152152
P 0 P 0
153153
#
154154
MAPPING SCRIPR
155-
../test_data/rmp_jra55_cice_patch.nc dst
155+
../test_data/ERA5_MOM1_patch.nc dst
156156
DISTWGT LR VECTOR LATLON 10 4 uwnd_ai
157157
############################################################################
158158
#

tests/ERA5/ocean.nml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
from_ice_field_names = 'u_flux', 'v_flux', 'lprec', 'fprec', 'salt_flx', 'mh_flux', 'sw_flux', 'q_flux', 't_flux', 'lw_flux', 'runof', 'p', 'aice', 'wfimelt', 'wfiform'
33
to_ice_field_names = 't_surf', 's_surf', 'u_surf', 'v_surf', 'dssldx', 'dssldy', 'frazil'
44
resolution(:) = 360,300
5-
dt = 5400
5+
dt = 3600
66
&end

0 commit comments

Comments
 (0)