73 Character(*),
Intent(in) :: filename_lut
75 Integer :: error_status
78 CHARACTER(*),
PARAMETER :: routine_name =
'load_bfield_lut' 79 Integer :: file_id, io_status
80 Character (len=80) :: message
81 Integer :: i, j, iskip
87 message =
'File '//trim(filename_lut)//
' not found.' 96 OPEN( file_id, file = filename_lut, &
98 & iostat = io_status )
100 IF ( io_status /= 0 )
THEN 102 WRITE( message,
'( "Error opening ", a, ". IOSTAT = ", i5 )' ) &
103 & trim(filename_lut), io_status
110 READ(file_id, *, iostat = io_status)iskip, iskip, &
113 If(io_status /= 0)
Then 115 Write( message,
'( "Error reading data from ", a, ". IOSTAT = ", i5 )' ) &
116 & trim(filename_lut), io_status
123 Close( unit = file_id )
265 REAL(fp),
INTENT(IN) :: latitude, longitude
266 REAL(fp),
INTENT(OUT) :: Bx, By, Bz, Be
269 REAL(fp) :: x2, w1_lat, w1_lon
270 INTEGER :: idx_lat, idx_lon
271 REAL(fp),
PARAMETER :: dlat = 2.0_fp, dlon = 2.0_fp
273 idx_lat = int(latitude/dlat)+1
275 idx_lon = int(longitude/dlat)+1
278 x2 =
REAL(idx_lat, fp)*dlat
279 w1_lat = (x2 - latitude)/dlat
281 x2 =
REAL(idx_lon, fp)*dlat
282 w1_lon = (x2 - longitude)/dlat
288 be = sqrt(bx*bx+by*by+bz*bz)
293 idx_lat, idx_lon)
Result(B)
295 INTEGER,
INTENT(IN) :: comp
296 INTEGER,
INTENT(IN) ::
bfield(:,:,:)
297 REAL(fp),
INTENT(IN) :: w1_lat, w1_lon
298 INTEGER,
INTENT(IN) :: idx_lat, idx_lon
302 REAL(fp),
PARAMETER :: scale = 0.001_fp
303 REAL(fp) :: w2_lat, w2_lon
305 w2_lat = 1.0_fp - w1_lat
306 w2_lon = 1.0_fp - w1_lon
307 b = (w1_lon*(w1_lat*
REAL(BField(comp,idx_lat, idx_lon), fp) + &
308 w2_lat*
REAL(BField(comp,idx_lat+1, idx_lon), fp)) &
309 + w2_lon*(w1_lat*
REAL(BField(comp,idx_lat, idx_lon+1),fp) + &
310 w2_lat*
REAL(BField(comp,idx_lat+1, idx_lon+1),fp)))*scale
316 Subroutine compute_bfield_f2(latitude, longitude, sensor_zenang, sensor_aziang, &
317 Be, cos_bkang, cos_baziang)
320 Real(fp),
Intent(in) :: latitude
321 Real(fp),
Intent(in) :: longitude
322 Real(fp),
Intent(in) :: sensor_zenang
323 Real(fp),
Intent(in) :: sensor_aziang
324 Real(fp),
Intent(out) :: Be
325 Real(fp),
Intent(out) :: cos_bkang
326 Real(fp),
Intent(out) :: cos_baziang
329 Real(fp) :: Bx, By, Bz
338 cos_bkang, cos_baziang)
343 sensor_relative_aziang, julian_day, utc_time, &
344 Be, cos_bkang, cos_baziang)
346 Real(fp),
Intent(in) :: latitude
347 Real(fp),
Intent(in) :: longitude
348 Real(fp),
Intent(in) :: sensor_zenang
349 Real(fp),
Intent(in) :: sensor_relative_aziang
350 Integer,
Intent(in) :: julian_day
351 Real(fp),
Intent(in) :: utc_time
352 Real(fp),
Intent(out) :: Be
353 Real(fp),
Intent(out) :: cos_bkang
354 Real(fp),
Intent(out) :: cos_baziang
357 Real(fp) :: Bx, By, Bz, Solar_ZA, Solar_AZ, lat, lon, sensor_aziang
364 lat = 90.0_fp - latitude
366 If(lon > 180.0_fp)lon = lon - 360.0_fp
368 Call solar_za_az(lat,lon,
Real(julian_day, fp), utc_time, &
371 sensor_aziang = sensor_relative_aziang + solar_az
372 sensor_aziang = 90.0_fp - sensor_aziang
376 cos_bkang, cos_baziang)
457 sensor_zenang, sensor_aziang, & ! Input
458 cos_bkang, cos_baziang)
459 REAL(fp),
INTENT(IN) :: bx, by, bz
460 REAL(fp),
INTENT(IN) :: sensor_zenang, sensor_aziang
461 REAL(fp),
INTENT(OUT) :: cos_bkang, cos_baziang
464 REAL(fp) :: b, b_v, b_h, b_p, kx, ky, kz, &
465 sin_senza, cos_senaz, sin_senaz, cos_senza
473 kx = sin_senza*cos_senaz
474 ky = sin_senza*sin_senaz
478 b = sqrt(bx*bx+by*by+bz*bz)
479 cos_bkang = (kx*bx + ky*by + kz*bz)/b
483 b_v = bx*kx*kz + by*ky*kz - bz*(ky*ky + kx*kx) ;
487 b_p = sqrt(b_v*b_v + b_h*b_h)
488 If(b_p /= 0.0_fp)
Then 489 cos_baziang = b_v / b_p
561 real(fp),
intent(in) :: latitude,longitude,julian_day,universal_time
562 real(fp),
intent(out) :: ZA, Az
564 real(fp) :: local_sun_time,solar_elevation,equation_of_time
565 real(fp) :: cosza,cosaz
566 real(fp) :: hour_angle,day_angle
567 real(fp) :: solar_declination
568 real(fp) :: rlatitude, rlongitude
569 real(fp),
parameter :: DEGREES_TO_RADIANS = 3.141592653589793238462643_fp/180.0_fp
570 real(fp),
parameter :: one_eighty_over_pi = 1.0/degrees_to_radians
571 real(fp),
parameter :: threesixty_over_24 = 15.0
572 real(fp),
parameter :: threesixty_over_365 = 0.98630137
573 real(fp),
parameter :: min_declination = -23.433
574 real(fp),
parameter :: day_offset = 10.0
578 day_angle = threesixty_over_365*(julian_day-1.0)*degrees_to_radians
580 rlatitude = latitude * degrees_to_radians
581 rlongitude = longitude * degrees_to_radians
587 + 0.001868*cos(day_angle) &
588 - 0.032077*sin(day_angle) &
589 - 0.014615*cos(2.*day_angle) &
590 - 0.040890*sin(2.*day_angle) )*229.18/60
593 local_sun_time = universal_time &
595 + longitude/threesixty_over_24
599 solar_declination = &
601 - 0.399912 * cos(day_angle) &
602 + 0.070257 * sin(day_angle) &
603 - 0.006758 * cos(2*day_angle) &
604 + 0.000907 * sin(2*day_angle) &
605 - 0.002697 * cos(3*day_angle) &
606 + 0.001480 * sin(3*day_angle) )
609 hour_angle = threesixty_over_24*mod(local_sun_time+12.0_fp , 24.0_fp)
612 cosza = sin(rlatitude)*sin(solar_declination) &
613 + cos(rlatitude)*cos(solar_declination)*cos(hour_angle*degrees_to_radians)
615 za = acos(cosza)*one_eighty_over_pi
618 solar_elevation = 90.0 - za
620 If(solar_elevation .eq. 90.0)
Then 623 cosaz = (sin(solar_elevation*degrees_to_radians)*sin(rlatitude) - &
624 sin(solar_declination)) / &
625 (cos(solar_elevation*degrees_to_radians)*cos(rlatitude))
627 If(cosaz .lt. -1.0) cosaz = -1.0
628 If(cosaz .gt. 1.0) cosaz = 1.0
630 az = acos(cosaz)*one_eighty_over_pi
636 If (az .ge. 0.0)
Then 642 If(hour_angle .lt. 180.0) az = - az
643 If(az .lt. 0) az = 360.0 + az
integer, parameter, public failure
integer, parameter, public fp
integer function, public load_bfield_lut(filename_LUT)
subroutine compute_bfield_f1(latitude, longitude, Bx, By, Bz, Be)
subroutine solar_za_az(latitude, longitude, julian_day, universal_time, ZA, Az)
integer function, public get_lun()
integer, dimension(3, n_lat, n_lon), save bfield
subroutine compute_bfield_f2(latitude, longitude, sensor_zenang, sensor_aziang, Be, cos_bkang, cos_baziang)
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
subroutine, public compute_kb_angles(Bx, By, Bz, sensor_zenang, sensor_aziang, cos_bkang, cos_baziang)
subroutine compute_bfield_f3(latitude, longitude, sensor_zenang, sensor_relative_aziang, julian_day, utc_time, Be, cos_bkang, cos_baziang)
real(fp), parameter, public degrees_to_radians
real(fp) function bfield_component(comp, Bfield, w1_lat, w1_lon, idx_lat, idx_lon)
integer, parameter, public success