1 subroutine da_med_initialdata_input (grid, config_flags, filename, in_date)
3 !-----------------------------------------------------------------------
5 !-----------------------------------------------------------------------
9 type(domain), intent(inout) :: grid
10 type (grid_config_rec_type), intent(inout) :: config_flags
12 character(*), intent (in) :: filename
13 character(*), intent (in), optional :: in_date
15 integer :: fid , status, n, nsave
17 integer :: julyr, julday
20 if (trace_use) call da_trace_entry("da_med_initialdata_input")
21 if (trace_use) call da_trace("da_med_initialdata_input", &
22 Message="Reading "//trim(filename))
24 ! Initialize the mother domain.
26 grid%input_from_file = .true.
28 call ext_ncd_open_for_read(trim(filename), 0, 0, "", fid, ierr)
31 write(unit=message(1), fmt='(2a)') &
32 'Netcdf error opening file:', trim(filename)
33 call da_error(__FILE__,__LINE__,message(1:1))
36 call ext_ncd_get_next_time(fid, current_date, Status)
38 if (present(in_date)) then
39 ! Set start_date to current_date.
40 read(in_date(1:19), fmt='(i4, 5(1x, i2))') &
50 if (current_date(1:19) == in_date(1:19)) then
54 call ext_ncd_get_next_time(fid, current_date, Status)
58 call da_error(__FILE__,__LINE__,(/"Cannot find the needed time"/))
61 ! Set start_date to current_date.
62 read(current_date(1:19), fmt='(i4, 5(1x, i2))') &
71 call geth_julgmt(julyr, julday, gmt)
72 call nl_set_gmt (grid%id, gmt)
73 call nl_set_julyr (grid%id, julyr)
74 call nl_set_julday (grid%id, julday)
76 call nl_set_iswater (grid%id, grid%iswater)
77 call nl_set_cen_lat (grid%id , grid%cen_lat)
78 call nl_set_cen_lon (grid%id , grid%cen_lon)
79 call nl_set_truelat1 (grid%id , grid%truelat1)
80 call nl_set_truelat2 (grid%id , grid%truelat2)
81 call nl_set_moad_cen_lat (grid%id , grid%moad_cen_lat)
82 call nl_set_stand_lon (grid%id , grid%stand_lon)
83 call nl_set_map_proj (grid%id , grid%map_proj)
85 start_date=current_date
87 call geth_julgmt(julyr, julday, gmt)
88 config_flags%gmt = gmt
89 config_flags%julyr = julyr
90 config_flags%julday = julday
92 call ext_ncd_ioclose(fid, ierr)
94 call da_trace("da_med_initialdata_input", &
95 message="open_r_dataset for "//trim(filename))
96 call open_r_dataset (fid, trim(filename), grid , config_flags , &
97 "DATASET=INPUT", ierr)
100 write(unit=message(1),fmt='(A,A,A,I5)') 'Error opening ', &
101 trim(filename),' for reading ierr=',ierr
102 call da_error(__FILE__,__LINE__,message(1:1))
105 if (present(in_date)) then
107 call da_message((/"current_date="//current_date// &
108 ', in_date='//in_date/))
109 call ext_ncd_get_next_time(fid, current_date, Status)
113 call input_input (fid , grid , config_flags , ierr)
115 call close_dataset (fid , config_flags , "DATASET=INPUT")
117 if (trace_use) call da_trace_exit("da_med_initialdata_input")
119 end subroutine da_med_initialdata_input