10 use musica_constants,
only : musica_dk
11 use musica_string,
only : string_t
22 type(string_t) :: name_
23 real(kind=musica_dk) :: density__kg_m3_
24 complex(kind=musica_dk),
allocatable :: shortwave_refractive_index_(:)
25 complex(kind=musica_dk),
allocatable :: longwave_refractive_index_(:)
51 use musica_assert,
only : assert_msg
52 use musica_config,
only : config_t
53 use musica_io,
only : io_t
54 use musica_io_netcdf,
only : io_netcdf_t
57 class(config_t),
intent(inout) :: config
59 character(len=*),
parameter :: my_name =
"species_t constructor"
60 class(io_t),
pointer :: file_ptr
61 type(string_t) :: file_path
62 type(string_t) :: sw_real_ri, sw_imag_ri, lw_real_ri, lw_imag_ri
63 type(config_t) :: optics
64 real(kind=musica_dk),
allocatable :: real_values(:), imag_values(:)
67 call config%get(
"name", new_obj%name_, my_name )
68 call config%get(
"density",
"kg m-3", new_obj%density__kg_m3_, my_name )
69 call config%get(
"optics", optics, my_name, found = found )
71 call optics%get(
"file path", file_path, my_name )
72 file_ptr => io_netcdf_t( file_path )
73 call optics%get(
"real refractive index - shortwave", sw_real_ri, &
75 call optics%get(
"real refractive index - longwave", lw_real_ri, &
77 call optics%get(
"imaginary refractive index - shortwave", sw_imag_ri, &
79 call optics%get(
"imaginary refractive index - longwave", lw_imag_ri, &
81 call file_ptr%read( sw_real_ri, real_values, my_name )
82 call file_ptr%read( sw_imag_ri, imag_values, my_name )
83 call assert_msg( 434735228, &
84 size( real_values ) .eq.
size( imag_values ), &
85 "Length mismatch for shortwave refractive index "// &
86 "arrays for species '"//new_obj%name_//
"'" )
87 allocate( new_obj%shortwave_refractive_index_(
size( real_values ) ) )
88 new_obj%shortwave_refractive_index_(:) = &
89 cmplx( real_values(:), abs( imag_values(:) ), kind = musica_dk )
90 deallocate( real_values )
91 deallocate( imag_values )
92 call file_ptr%read( lw_real_ri, real_values, my_name )
93 call file_ptr%read( lw_imag_ri, imag_values, my_name )
94 call assert_msg( 979080793, &
95 size( real_values ) .eq.
size( imag_values ), &
96 "Length mismatch for longwave refractive index "// &
97 "arrays for species '"//new_obj%name_//
"'" )
98 allocate( new_obj%longwave_refractive_index_(
size( real_values ) ) )
99 new_obj%longwave_refractive_index_(:) = &
100 cmplx( real_values(:), abs( imag_values(:) ), kind = musica_dk )
101 deallocate( file_ptr )
103 new_obj%shortwave_refractive_index_(:) = cmplx( 0.0, 0.0 )
104 new_obj%longwave_refractive_index_(:) = cmplx( 0.0, 0.0 )
112 type(string_t) function
name( this )
123 real(kind=musica_dk)
elemental function volume__m3( this, species_mass__kg )
126 real(kind=musica_dk),
intent(in) :: species_mass__kg
128 volume__m3 = species_mass__kg / this%density__kg_m3_
139 integer,
intent(in) :: band
152 integer,
intent(in) :: band
The species_t type and related functions.
type(species_t) function constructor(config)
Constructs species_t objects.
type(string_t) function name(this)
Returns the species name.
real(kind=musica_dk) elemental function volume__m3(this, species_mass__kg)
Returns the total volume occupied by the species for a given mass.
complex(kind=musica_dk) elemental function longwave_refractive_index(this, band)
Returns the longwave refractive index at a specified band index.
complex(kind=musica_dk) elemental function shortwave_refractive_index(this, band)
Returns the shortwave refractive index at a specified band index.