24   USE def_spectrum, 
ONLY: strspecdata
 
   95     type(model_state_type), 
target, 
intent(inout) :: current_state
 
   99     k_top=current_state%local_grid%size(z_index) + current_state%local_grid%halo_size(z_index) * 2
 
  100     y_local=current_state%local_grid%size(y_index) + current_state%local_grid%halo_size(y_index) * 2
 
  101     x_local=current_state%local_grid%size(x_index) + current_state%local_grid%halo_size(x_index) * 2
 
  103     y_nohalos=current_state%local_grid%size(y_index)
 
  104     x_nohalos=current_state%local_grid%size(x_index) 
 
  168             current_state%global_grid%configuration%vertical%rhon(k)* &
 
  169             current_state%global_grid%configuration%vertical%dz(k)
 
  177     call set_and_test_socrates_monc_options(current_state, 
socrates_opt)
 
  180     call sw_input(current_state)
 
  182     call read_spectrum( sw_control%spectral_file,                  &
 
  187     call lw_input(current_state, lw_control)
 
  188     call read_spectrum( lw_control%spectral_file,                  &
 
  193     call read_mcclatchey_profiles(current_state, 
mcc)
 
  197     call calculate_radiation_levels(current_state, 
mcc)
 
  208     type(model_state_type), 
target, 
intent(inout) :: current_state
 
  210     real(DEFAULT_PRECISION), 
parameter :: &
 
  212     real(DEFAULT_PRECISION) :: local_dtm  
 
  213     integer :: icol, jcol 
 
  214     integer :: target_x_index, target_y_index
 
  220     if (current_state%halo_column .or. current_state%timestep < 2) 
return 
  222     local_dtm = current_state%dtm*2.0
 
  223     if (current_state%field_stepping == forward_stepping) local_dtm=current_state%dtm
 
  226     icol=current_state%column_local_x 
 
  227     jcol=current_state%column_local_y
 
  229     target_y_index=jcol-current_state%local_grid%halo_size(y_index)
 
  230     target_x_index=icol-current_state%local_grid%halo_size(x_index)
 
  237     if (current_state%first_nonhalo_timestep_column) 
then 
  240        if (
socrates_opt%rad_int_time <= 0.0 .or. current_state%timestep == 2 ) 
then 
  244                ((current_state%time - &
 
  245                (current_state%rad_last_time + 
socrates_opt%rad_int_time)) > 0.0)
 
  250        if (current_state%first_nonhalo_timestep_column) 
then 
  251           call log_master_log &
 
  252                (log_info, 
"Socrates called, time ="//trim(conv_to_string(current_state%time))//&
 
  253                " rad_int_time="//trim(conv_to_string(
socrates_opt%rad_int_time))//&
 
  254                " local dtm="//trim(conv_to_string(local_dtm)))
 
  255           call log_master_log &
 
  256                (log_info, 
"methane ="//trim(conv_to_string(
socrates_opt%ch4_mmr))//&
 
  257                " l_ch4="//trim(conv_to_string(lw_control%l_ch4)))
 
  262                int((
socrates_opt%rad_start_time + (current_state%time/3600.0))/24.0)
 
  264                (
socrates_opt%rad_start_time + ((current_state%time+local_dtm)/3600.0))  &
 
  274           current_state%rad_last_time = current_state%time
 
  281        if (current_state%use_surface_boundary_conditions) 
then 
  282           if (current_state%type_of_surface_boundary_conditions == prescribed_surface_values) 
then 
  284                   current_state%theta_surf /           &
 
  285                   ((current_state%surface_reference_pressure/current_state%surface_pressure)**r_over_cp)
 
  286           elseif (current_state%type_of_surface_boundary_conditions == prescribed_surface_fluxes) 
then 
  289                   (current_state%th%data(2, jcol, icol)        &
 
  290                   + current_state%global_grid%configuration%vertical%thref(2))   &
 
  291                   * current_state%global_grid%configuration%vertical%rprefrcp(2)
 
  296                (current_state%th%data(2, jcol, icol)        &
 
  297                + current_state%global_grid%configuration%vertical%thref(2))   &
 
  298                * current_state%global_grid%configuration%vertical%rprefrcp(2)
 
  387     current_state%sth%data(:, jcol, icol) = &
 
  388          current_state%sth%data(:, jcol, icol) +  &
 
  389          current_state%sth_lw%data(:, jcol, icol) + &
 
  390          current_state%sth_sw%data(:, jcol, icol)
 
  396     type(model_state_type), 
target, 
intent(inout) :: current_state
 
  408     type(model_state_type), 
target, 
intent(inout) :: current_state
 
  409    character(len=*), 
intent(in) :: name
 
  410    type(component_field_information_type), 
intent(out) :: field_information
 
  412    if ( name .eq. 
"flux_up_shortwave" .or. name .eq. 
"flux_down_shortwave"  .or.  &
 
  413         name .eq. 
"flux_up_longwave" .or. name .eq. 
"flux_down_longwave" .or.     &
 
  414         name .eq. 
"shortwave_heating_rate" .or. name .eq. 
"longwave_heating_rate" &
 
  415         .or. name .eq. 
"total_radiative_heating_rate") 
then 
  416       field_information%field_type=component_array_field_type
 
  417       field_information%number_dimensions=3
 
  418       field_information%dimension_sizes(1)=current_state%local_grid%size(z_index)
 
  419       field_information%dimension_sizes(2)=current_state%local_grid%size(y_index)
 
  420       field_information%dimension_sizes(3)=current_state%local_grid%size(x_index)
 
  421       field_information%data_type=component_double_data_type
 
  423       field_information%field_type=component_array_field_type
 
  424       field_information%number_dimensions=2
 
  425       field_information%dimension_sizes(1)=current_state%local_grid%size(y_index)
 
  426       field_information%dimension_sizes(2)=current_state%local_grid%size(x_index)
 
  427       field_information%data_type=component_double_data_type
 
  430    field_information%enabled=.true.
 
  439    type(model_state_type), 
target, 
intent(inout) :: current_state
 
  440    character(len=*), 
intent(in) :: name
 
  441    type(component_field_value_type), 
intent(out) :: field_value
 
  446    if (name .eq. 
"flux_up_shortwave") 
then 
  447       allocate(field_value%real_3d_array(current_state%local_grid%size(z_index),  &
 
  448            current_state%local_grid%size(y_index),                                &
 
  449            current_state%local_grid%size(x_index)))
 
  451    else if (name .eq. 
"flux_down_shortwave") 
then 
  452       allocate(field_value%real_3d_array(current_state%local_grid%size(z_index),  &
 
  453            current_state%local_grid%size(y_index),                                &
 
  454            current_state%local_grid%size(x_index)))
 
  456    else if (name .eq. 
"flux_up_longwave") 
then 
  457       allocate(field_value%real_3d_array(current_state%local_grid%size(z_index),  &
 
  458            current_state%local_grid%size(y_index),                                &
 
  459            current_state%local_grid%size(x_index)))
 
  461    else if (name .eq. 
"flux_down_longwave") 
then 
  462       allocate(field_value%real_3d_array(current_state%local_grid%size(z_index),  &
 
  463            current_state%local_grid%size(y_index),                                &
 
  464            current_state%local_grid%size(x_index)))
 
  466    else if (name .eq. 
"shortwave_heating_rate") 
then 
  467       allocate(field_value%real_3d_array(current_state%local_grid%size(z_index),  &
 
  468            current_state%local_grid%size(y_index),                                &
 
  469            current_state%local_grid%size(x_index)))
 
  471    else if (name .eq. 
"longwave_heating_rate") 
then 
  472       allocate(field_value%real_3d_array(current_state%local_grid%size(z_index),  &
 
  473            current_state%local_grid%size(y_index),                                &
 
  474            current_state%local_grid%size(x_index)))
 
  476    else if (name .eq. 
"total_radiative_heating_rate") 
then 
  477       allocate(field_value%real_3d_array(current_state%local_grid%size(z_index),  &
 
  478            current_state%local_grid%size(y_index),                                &
 
  479            current_state%local_grid%size(x_index)))
 
  483    else if (name .eq. 
"toa_up_longwave") 
then 
  484       allocate(field_value%real_2d_array(current_state%local_grid%size(y_index),   &
 
  485            current_state%local_grid%size(x_index)))
 
  487    else if (name .eq. 
"surface_down_longwave") 
then 
  488       allocate(field_value%real_2d_array(current_state%local_grid%size(y_index),   &
 
  489            current_state%local_grid%size(x_index)))
 
  491    else if (name .eq. 
"surface_up_longwave") 
then 
  492       allocate(field_value%real_2d_array(current_state%local_grid%size(y_index),   &
 
  493            current_state%local_grid%size(x_index)))
 
  495    else if (name .eq. 
"toa_up_shortwave") 
then 
  496       allocate(field_value%real_2d_array(current_state%local_grid%size(y_index),   &
 
  497            current_state%local_grid%size(x_index)))
 
  499    else if (name .eq. 
"toa_down_shortwave") 
then 
  500       allocate(field_value%real_2d_array(current_state%local_grid%size(y_index),   &
 
  501            current_state%local_grid%size(x_index)))
 
  503    else if (name .eq. 
"surface_down_shortwave") 
then 
  504       allocate(field_value%real_2d_array(current_state%local_grid%size(y_index),   &
 
  505            current_state%local_grid%size(x_index)))
 
  507    else if (name .eq. 
"surface_up_shortwave") 
then 
  508       allocate(field_value%real_2d_array(current_state%local_grid%size(y_index),   &
 
  509            current_state%local_grid%size(x_index)))