Restart error when hist_empty_htapes = .true. and no h0 history fields are requested
- Dominant language
- Fortran
- Stars
- 352
- Forks
- 361
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
### Brief summary of bug
A user reports an error at restart when hist_empty_htapes = .true. and no h0 history fields are requested
### General bug information
**CTSM version you are using:** ctsm5.3.005 (user), ctsm5.3.063 (my verification)
**Does this bug cause significantly incorrect results in the model's science?** No
**Configurations affected:**
### Details of bug
The following error is encountered at restart when hist_empty_htapes = .true. and no h0 history fields are requested:
```
(GETFIL): attempting to find local file
ctsm53063_CRUJRA2024_1deg_emptyh0_2000.clm2.rh1a.2000-02-01-00000.nc
(GETFIL): using ctsm53063_CRUJRA2024_1deg_emptyh0_2000.clm2.rh1a.2000-02-01-00000.nc in current working directory
ERROR: reading variable: num2d ERROR in /glade/work/oleson/ctsm5.3.063/src/mai
n/ncdio_pio.F90.in at line 1508
```
Traceback is:
```
dec0643.hsn.de.hpc.ucar.edu 1909: cesm.exe 00000000011B3DB2 shr_abort_mod_mp_ 110 shr_abort_mod.F90
dec0643.hsn.de.hpc.ucar.edu 1909: cesm.exe 00000000005C5E1B ncdio_pio_mp_ncd_ 1507 ncdio_pio.F90.in
dec0643.hsn.de.hpc.ucar.edu 1909: cesm.exe 00000000006D8545 histfilemod_mp_hi 4950 histFileMod.F90
dec0643.hsn.de.hpc.ucar.edu 1909: cesm.exe 00000000007560BC restfilemod_mp_re 220 restFileMod.F90
dec0643.hsn.de.hpc.ucar.edu 1909: cesm.exe 00000000005FFA30 clm_initializemod 546 clm_initializeMod.F90
dec0643.hsn.de.hpc.ucar.edu 1909: cesm.exe 00000000005A3330 lnd_comp_nuopc_mp 664 lnd_comp_nuopc.F90
```
### Important details of your setup / configuration so we can reproduce the bug
I reproduced the error with this case (1 month run and then restart):
/glade/work/oleson/ctsm5.3.063/cime/scripts/ctsm53063_CRUJRA2024_1deg_emptyh0_2000
In particular the following history file settings are associated with the error:
hist_dov2xy(2) = .true.
hist_dov2xy(3) = .false.
hist_empty_htapes = .true.
hist_fields_list_file = .false.
hist_fincl2 = 'TSA', 'TSA_R', 'TSA_U', 'RH2M', 'RH2M_U', 'RH2M_R', 'EFLX_LH_TOT', 'EFLX_LH_TOT_R', 'EFLX_LH_TOT_U', 'FSH_R',
'FSH_U', 'FSH', 'WASTEHEAT', 'HEAT_FROM_AC', 'URBAN_HEAT', 'FIRE', 'FIRE_U', 'FIRA', 'FIRA_U', 'FSA',
'FSA_U', 'FGR_U', 'FGR'
hist_fincl3 = 'TSA','RH2M','EFLX_LH_TOT','FSH','FIRE','FSA','FGR'
hist_mfilt(2) = 1
hist_mfilt(3) = 1
hist_nhtfrq(2) = -24
hist_nhtfrq(3) = -24
hist_type1d_pertape(3) = 'COLS'
The key is that hist_empty_htapes = .true., and there are no h0 fields requested.
I think it might be because the array itemp associated with line 4950 in histFileMod.F90 is not allocated in this case:
```
call ncd_io(varname='num2d', data=itemp(:), ncid=ncid_hist(t,f), flag='read')
```
Contributor guide
Assessment
This issue has not been assessed yet.