FV3 Bundle
CRTM_MW_Water_SfcOptics.f90
Go to the documentation of this file.
1 !
2 ! CRTM_MW_Water_SfcOptics
3 !
4 ! Module to compute the surface optical properties for WATER surfaces at
5 ! microwave frequencies required for determining the WATER surface
6 ! contribution to the radiative transfer.
7 !
8 ! This module is provided to allow developers to "wrap" their existing
9 ! codes inside the provided functions to simplify integration into
10 ! the main CRTM_SfcOptics module.
11 !
12 !
13 ! CREATION HISTORY:
14 ! Written by: Paul van Delst, 25-Jun-2005
15 ! paul.vandelst@noaa.gov
16 !
17 
19 
20  ! -----------------
21  ! Environment setup
22  ! -----------------
23  ! Module use
24  USE type_kinds, ONLY: fp
25  USE message_handler, ONLY: success
26  USE crtm_parameters, ONLY: set, not_set, &
27  zero, one, &
28  max_n_angles, &
29  n_stokes => max_n_stokes
30  USE crtm_spccoeff, ONLY: sc
35  USE crtm_lowfrequency_mwssem, ONLY: lf_mwssem_type => ivar_type, &
39  USE crtm_fastem1, ONLY: fastem1
40  USE crtm_fastemx, ONLY: fastemx_type => ivar_type, &
44  USE crtm_mwwatercoeff , ONLY: mwwaterc
45  ! Disable implicit typing
46  IMPLICIT NONE
47 
48 
49  ! ------------
50  ! Visibilities
51  ! ------------
52  ! Everything private by default
53  PRIVATE
54  ! Data types
55  PUBLIC :: ivar_type
56  ! Science routines
60 
61 
62  ! -----------------
63  ! Module parameters
64  ! -----------------
65  ! RCS Id for the module
66  CHARACTER(*), PARAMETER :: module_version_id = &
67  '$Id: CRTM_MW_Water_SfcOptics.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $'
68  ! Low frequency model threshold
69  REAL(fp), PARAMETER :: low_f_threshold = 20.0_fp ! GHz
70 
71 
72  ! --------------------------------------
73  ! Structure definition to hold forward
74  ! variables across FWD, TL, and AD calls
75  ! --------------------------------------
76  TYPE :: ivar_type
77  PRIVATE
78  ! FastemX model internal variable structure
79  TYPE(fastemx_type) :: fastemx_var
80  ! Low frequency model internal variable structure
81  TYPE(lf_mwssem_type) :: lf_mwssem_var
82  ! Fastem outputs
83  REAL(fp), DIMENSION(MAX_N_ANGLES) :: deh_dts = zero
84  REAL(fp), DIMENSION(MAX_N_ANGLES) :: deh_dwindspeed = zero
85  REAL(fp), DIMENSION(MAX_N_ANGLES) :: dev_dts = zero
86  REAL(fp), DIMENSION(MAX_N_ANGLES) :: dev_dwindspeed = zero
87  END TYPE ivar_type
88 
89 CONTAINS
90 
91 
92 
93 !----------------------------------------------------------------------------------
94 !:sdoc+:
95 !
96 ! NAME:
97 ! Compute_MW_Water_SfcOptics
98 !
99 ! PURPOSE:
100 ! Function to compute the surface emissivity and reflectivity at microwave
101 ! frequencies over a water surface.
102 !
103 ! This function is a wrapper for third party code.
104 !
105 ! CALLING SEQUENCE:
106 ! Error_Status = Compute_MW_Water_SfcOptics( Surface , & ! Input
107 ! GeometryInfo, & ! Input
108 ! SensorIndex , & ! Input
109 ! ChannelIndex, & ! Input
110 ! SfcOptics , & ! Output
111 ! iVar ) ! Internal variable output
112 !
113 ! INPUTS:
114 ! Surface: CRTM_Surface structure containing the surface state
115 ! data.
116 ! UNITS: N/A
117 ! TYPE: CRTM_Surface_type
118 ! DIMENSION: Scalar
119 ! ATTRIBUTES: INTENT(IN)
120 !
121 ! GeometryInfo: CRTM_GeometryInfo structure containing the
122 ! view geometry information.
123 ! UNITS: N/A
124 ! TYPE: CRTM_GeometryInfo_type
125 ! DIMENSION: Scalar
126 ! ATTRIBUTES: INTENT(IN)
127 !
128 ! SensorIndex: Sensor index id. This is a unique index associated
129 ! with a (supported) sensor used to access the
130 ! shared coefficient data for a particular sensor.
131 ! See the ChannelIndex argument.
132 ! UNITS: N/A
133 ! TYPE: INTEGER
134 ! DIMENSION: Scalar
135 ! ATTRIBUTES: INTENT(IN)
136 !
137 ! ChannelIndex: Channel index id. This is a unique index associated
138 ! with a (supported) sensor channel used to access the
139 ! shared coefficient data for a particular sensor's
140 ! channel.
141 ! See the SensorIndex argument.
142 ! UNITS: N/A
143 ! TYPE: INTEGER
144 ! DIMENSION: Scalar
145 ! ATTRIBUTES: INTENT(IN)
146 !
147 ! OUTPUTS:
148 ! SfcOptics: CRTM_SfcOptics structure containing the surface
149 ! optical properties required for the radiative
150 ! transfer calculation. On input the Angle component
151 ! is assumed to contain data.
152 ! UNITS: N/A
153 ! TYPE: CRTM_SfcOptics_type
154 ! DIMENSION: Scalar
155 ! ATTRIBUTES: INTENT(IN OUT)
156 !
157 ! iVar: Structure containing internal variables required for
158 ! subsequent tangent-linear or adjoint model calls.
159 ! The contents of this structure are NOT accessible
160 ! outside of the CRTM_MW_Water_SfcOptics module.
161 ! UNITS: N/A
162 ! TYPE: iVar_type
163 ! DIMENSION: Scalar
164 ! ATTRIBUTES: INTENT(OUT)
165 !
166 ! FUNCTION RESULT:
167 ! Error_Status: The return value is an integer defining the error status.
168 ! The error codes are defined in the Message_Handler module.
169 ! If == SUCCESS the computation was sucessful
170 ! == FAILURE an unrecoverable error occurred
171 ! UNITS: N/A
172 ! TYPE: INTEGER
173 ! DIMENSION: Scalar
174 !
175 ! COMMENTS:
176 ! Note the INTENT on the output SfcOptics argument is IN OUT rather
177 ! than just OUT as it is assumed to contain some data upon input.
178 !
179 !:sdoc-:
180 !----------------------------------------------------------------------------------
181 
182  FUNCTION compute_mw_water_sfcoptics( &
183  Surface , & ! Input
184  GeometryInfo, & ! Input
185  SensorIndex , & ! Input
186  ChannelIndex, & ! Input
187  SfcOptics , & ! Output
188  iVar ) & ! Internal variable output
189  result( err_stat )
190  ! Arguments
191  TYPE(crtm_surface_type), INTENT(IN) :: surface
192  TYPE(crtm_geometryinfo_type), INTENT(IN) :: geometryinfo
193  INTEGER, INTENT(IN) :: sensorindex
194  INTEGER, INTENT(IN) :: channelindex
195  TYPE(crtm_sfcoptics_type), INTENT(IN OUT) :: sfcoptics
196  TYPE(ivar_type), INTENT(IN OUT) :: ivar
197  ! Function result
198  INTEGER :: err_stat
199  ! Local parameters
200  CHARACTER(*), PARAMETER :: routine_name = 'Compute_MW_Water_SfcOptics'
201  ! Local variables
202  INTEGER :: i, j
203  REAL(fp) :: frequency
204  REAL(fp) :: source_azimuth_angle, sensor_azimuth_angle
205  REAL(fp) :: reflectivity(n_stokes)
206 
207 
208  ! Set up
209  err_stat = success
210  sfcoptics%Reflectivity = zero
211  ! ...Retrieve data from structures
212  frequency = sc(sensorindex)%Frequency(channelindex)
214  geometryinfo, &
215  source_azimuth_angle = source_azimuth_angle, &
216  sensor_azimuth_angle = sensor_azimuth_angle )
217 
218 
219  ! Compute the surface optical parameters
220  IF( sfcoptics%Use_New_MWSSEM ) THEN
221 
222  ! FastemX model
223  sfcoptics%Azimuth_Angle = surface%Wind_Direction - sensor_azimuth_angle
224  DO i = 1, sfcoptics%n_Angles
225  CALL compute_fastemx( &
226  mwwaterc , & ! Input model coefficients
227  frequency , & ! Input
228  sfcoptics%Angle(i) , & ! Input
229  surface%Water_Temperature , & ! Input
230  surface%Salinity , & ! Input
231  surface%Wind_Speed , & ! Input
232  ivar%FastemX_Var , & ! Internal variable output
233  sfcoptics%Emissivity(i,:) , & ! Output
234  reflectivity , & ! Output
235  azimuth_angle = sfcoptics%Azimuth_Angle, & ! Optional input
236  transmittance = sfcoptics%Transmittance ) ! Optional input
237  DO j = 1, n_stokes
238  sfcoptics%Reflectivity(i,j,i,j) = reflectivity(j)
239  END DO
240  END DO
241 
242  ELSE
243 
244  ! Low frequency model coupled with Fastem1
245  IF( frequency < low_f_threshold ) THEN
246  ! Call the low frequency model
247  DO i = 1, sfcoptics%n_Angles
248  CALL lowfrequency_mwssem( &
249  frequency , & ! Input
250  sfcoptics%Angle(i) , & ! Input
251  surface%Water_Temperature, & ! Input
252  surface%Salinity , & ! Input
253  surface%Wind_Speed , & ! Input
254  sfcoptics%Emissivity(i,:), & ! Output
255  ivar%LF_MWSSEM_Var ) ! Internal variable output
256  sfcoptics%Reflectivity(i,1,i,1) = one-sfcoptics%Emissivity(i,1)
257  sfcoptics%Reflectivity(i,2,i,2) = one-sfcoptics%Emissivity(i,2)
258  END DO
259  ELSE
260  ! Call Fastem1
261  DO i = 1, sfcoptics%n_Angles
262  CALL fastem1( frequency , & ! Input
263  sfcoptics%Angle(i) , & ! Input
264  surface%Water_Temperature, & ! Input
265  surface%Wind_Speed , & ! Input
266  sfcoptics%Emissivity(i,:), & ! Output
267  ivar%dEH_dWindSpeed(i) , & ! Output
268  ivar%dEV_dWindSpeed(i) ) ! Output
269  sfcoptics%Reflectivity(i,1,i,1) = one-sfcoptics%Emissivity(i,1)
270  sfcoptics%Reflectivity(i,2,i,2) = one-sfcoptics%Emissivity(i,2)
271  END DO
272  END IF
273 
274  END IF
275 
276  END FUNCTION compute_mw_water_sfcoptics
277 
278 
279 !----------------------------------------------------------------------------------
280 !:sdoc+:
281 !
282 ! NAME:
283 ! Compute_MW_Water_SfcOptics_TL
284 !
285 ! PURPOSE:
286 ! Function to compute the tangent-linear surface emissivity and
287 ! reflectivity at microwave frequencies over a water surface.
288 !
289 ! This function is a wrapper for third party code.
290 !
291 ! CALLING SEQUENCE:
292 ! Error_Status = Compute_MW_Water_SfcOptics_TL( Surface , & ! Input
293 ! SfcOptics , & ! Input
294 ! Surface_TL , & ! Input
295 ! GeometryInfo, & ! Input
296 ! SensorIndex , & ! Input
297 ! ChannelIndex, & ! Output
298 ! SfcOptics_TL, & ! Output
299 ! iVar ) ! Internal variable input
300 !
301 ! INPUTS:
302 ! Surface: CRTM_Surface structure containing the surface state
303 ! data.
304 ! UNITS: N/A
305 ! TYPE: CRTM_Surface_type
306 ! DIMENSION: Scalar
307 ! ATTRIBUTES: INTENT(IN)
308 !
309 ! Surface_TL: CRTM_Surface structure containing the tangent-linear
310 ! surface state data.
311 ! UNITS: N/A
312 ! TYPE: CRTM_Surface_type
313 ! DIMENSION: Scalar
314 ! ATTRIBUTES: INTENT(IN)
315 !
316 ! SfcOptics: CRTM_SfcOptics structure containing the surface
317 ! optical properties required for the radiative
318 ! transfer calculation.
319 ! UNITS: N/A
320 ! TYPE: CRTM_SfcOptics_type
321 ! DIMENSION: Scalar
322 ! ATTRIBUTES: INTENT(IN)
323 !
324 ! GeometryInfo: CRTM_GeometryInfo structure containing the
325 ! view geometry information.
326 ! UNITS: N/A
327 ! TYPE: CRTM_GeometryInfo_type
328 ! DIMENSION: Scalar
329 ! ATTRIBUTES: INTENT(IN)
330 !
331 ! SensorIndex: Sensor index id. This is a unique index associated
332 ! with a (supported) sensor used to access the
333 ! shared coefficient data for a particular sensor.
334 ! See the ChannelIndex argument.
335 ! UNITS: N/A
336 ! TYPE: INTEGER
337 ! DIMENSION: Scalar
338 ! ATTRIBUTES: INTENT(IN)
339 !
340 ! ChannelIndex: Channel index id. This is a unique index associated
341 ! with a (supported) sensor channel used to access the
342 ! shared coefficient data for a particular sensor's
343 ! channel.
344 ! See the SensorIndex argument.
345 ! UNITS: N/A
346 ! TYPE: INTEGER
347 ! DIMENSION: Scalar
348 ! ATTRIBUTES: INTENT(IN)
349 !
350 ! iVar: Structure containing internal variables required for
351 ! subsequent tangent-linear or adjoint model calls.
352 ! The contents of this structure are NOT accessible
353 ! outside of the CRTM_MW_Water_SfcOptics module.
354 ! UNITS: N/A
355 ! TYPE: iVar_type
356 ! DIMENSION: Scalar
357 ! ATTRIBUTES: INTENT(IN)
358 !
359 ! OUTPUT ARGUMENTS:
360 ! SfcOptics_TL: CRTM_SfcOptics structure containing the tangent-linear
361 ! surface optical properties required for the tangent-
362 ! linear radiative transfer calculation.
363 ! UNITS: N/A
364 ! TYPE: TYPE(CRTM_SfcOptics_type)
365 ! DIMENSION: Scalar
366 ! ATTRIBUTES: INTENT(IN OUT)
367 !
368 ! FUNCTION RESULT:
369 ! Error_Status: The return value is an integer defining the error status.
370 ! The error codes are defined in the Message_Handler module.
371 ! If == SUCCESS the computation was sucessful
372 ! == FAILURE an unrecoverable error occurred
373 ! UNITS: N/A
374 ! TYPE: INTEGER
375 ! DIMENSION: Scalar
376 !
377 ! COMMENTS:
378 ! Note the INTENT on the output SfcOptics_TL argument is IN OUT rather
379 ! than just OUT. This is necessary because the argument may be defined
380 ! upon input. To prevent memory leaks, the IN OUT INTENT is a must.
381 !
382 !:sdoc-:
383 !----------------------------------------------------------------------------------
384 
386  SfcOptics , & ! Input
387  Surface_TL , & ! Input
388  GeometryInfo, & ! Input
389  SensorIndex , & ! Input
390  ChannelIndex, & ! Input
391  SfcOptics_TL, & ! Output
392  iVar ) & ! Internal variable input
393  result( err_stat )
394  ! Arguments
395  TYPE(crtm_surface_type), INTENT(IN) :: surface_tl
396  TYPE(crtm_sfcoptics_type), INTENT(IN) :: sfcoptics
397  TYPE(crtm_geometryinfo_type), INTENT(IN) :: geometryinfo
398  INTEGER, INTENT(IN) :: sensorindex
399  INTEGER, INTENT(IN) :: channelindex
400  TYPE(crtm_sfcoptics_type), INTENT(IN OUT) :: sfcoptics_tl
401  TYPE(ivar_type), INTENT(IN) :: ivar
402  ! Function result
403  INTEGER :: err_stat
404  ! Local parameters
405  CHARACTER(*), PARAMETER :: routine_name = 'Compute_MW_Water_SfcOptics_TL'
406  ! Local variables
407  INTEGER :: i, j
408  REAL(fp) :: frequency
409  REAL(fp) :: source_azimuth_angle, sensor_azimuth_angle
410  REAL(fp) :: reflectivity_tl(n_stokes)
411 
412 
413  ! Set up
414  err_stat = success
415  sfcoptics_tl%Reflectivity = zero
416  ! ...Retrieve data from structures
417  frequency = sc(sensorindex)%Frequency(channelindex)
419  geometryinfo, &
420  source_azimuth_angle = source_azimuth_angle, &
421  sensor_azimuth_angle = sensor_azimuth_angle )
422 
423 
424  ! Compute the tangent-linear surface optical parameters
425  IF( sfcoptics%Use_New_MWSSEM ) THEN
426 
427  ! FastemX model
428  DO i = 1, sfcoptics%n_Angles
429  CALL compute_fastemx_tl( &
430  mwwaterc , & ! Input model coefficients
431  surface_tl%Water_Temperature , & ! TL Input
432  surface_tl%Salinity , & ! TL Input
433  surface_tl%Wind_Speed , & ! TL Input
434  ivar%FastemX_Var , & ! Internal variable input
435  sfcoptics_tl%Emissivity(i,:) , & ! TL Output
436  reflectivity_tl , & ! TL Output
437  azimuth_angle_tl = surface_tl%Wind_Direction, & ! Optional TL input
438  transmittance_tl = sfcoptics_tl%Transmittance ) ! Optional TL input
439  DO j = 1, n_stokes
440  sfcoptics_tl%Reflectivity(i,j,i,j) = reflectivity_tl(j)
441  END DO
442  END DO
443 
444  ELSE
445 
446  ! Low frequency model coupled with Fastem1
447  IF( frequency < low_f_threshold ) THEN
448  ! Call the low frequency model
449  DO i = 1, sfcoptics%n_Angles
450  CALL lowfrequency_mwssem_tl( &
451  surface_tl%Water_Temperature, & ! TL Input
452  surface_tl%Salinity , & ! TL Input
453  surface_tl%Wind_Speed , & ! TL Input
454  sfcoptics_tl%Emissivity(i,:), & ! TL Output
455  ivar%LF_MWSSEM_Var ) ! Internal variable input
456  sfcoptics_tl%Reflectivity(i,1,i,1) = -sfcoptics_tl%Emissivity(i,1)
457  sfcoptics_tl%Reflectivity(i,2,i,2) = -sfcoptics_tl%Emissivity(i,2)
458  END DO
459  ELSE
460  ! Call Fastem1
461  DO i = 1, sfcoptics%n_Angles
462  sfcoptics_tl%Emissivity(i,2) = (ivar%dEH_dTs(i)*surface_tl%Water_Temperature) + &
463  (ivar%dEH_dWindSpeed(i)*surface_tl%Wind_Speed)
464  sfcoptics_tl%Emissivity(i,1) = (ivar%dEV_dTs(i)*surface_tl%Water_Temperature) + &
465  (ivar%dEV_dWindSpeed(i)*surface_tl%Wind_Speed)
466  sfcoptics_tl%Reflectivity(i,1,i,1) = -sfcoptics_tl%Emissivity(i,1)
467  sfcoptics_tl%Reflectivity(i,2,i,2) = -sfcoptics_tl%Emissivity(i,2)
468  END DO
469  END IF
470  END IF
471 
472  END FUNCTION compute_mw_water_sfcoptics_tl
473 
474 
475 !----------------------------------------------------------------------------------
476 !
477 ! NAME:
478 ! Compute_MW_Water_SfcOptics_AD
479 !
480 ! PURPOSE:
481 ! Function to compute the adjoint surface emissivity and
482 ! reflectivity at microwave frequencies over a water surface.
483 !
484 ! This function is a wrapper for third party code.
485 !
486 ! CALLING SEQUENCE:
487 ! Error_Status = Compute_MW_Water_SfcOptics_AD( Surface , & ! Input
488 ! SfcOptics , & ! Input
489 ! SfcOptics_AD, & ! Input
490 ! GeometryInfo, & ! Input
491 ! SensorIndex , & ! Input
492 ! ChannelIndex, & ! Output
493 ! Surface_AD , & ! Output
494 ! iVar ) ! Internal variable input
495 !
496 ! INPUT ARGUMENTS:
497 ! Surface: CRTM_Surface structure containing the surface state
498 ! data.
499 ! UNITS: N/A
500 ! TYPE: TYPE(CRTM_Surface_type)
501 ! DIMENSION: Scalar
502 ! ATTRIBUTES: INTENT(IN)
503 !
504 ! SfcOptics: CRTM_SfcOptics structure containing the surface
505 ! optical properties required for the radiative
506 ! transfer calculation.
507 ! UNITS: N/A
508 ! TYPE: TYPE(CRTM_SfcOptics_type)
509 ! DIMENSION: Scalar
510 ! ATTRIBUTES: INTENT(IN)
511 !
512 ! SfcOptics_AD: CRTM_SfcOptics structure containing the adjoint
513 ! surface optical properties required for the adjoint
514 ! radiative transfer calculation.
515 ! UNITS: N/A
516 ! TYPE: TYPE(CRTM_SfcOptics_type)
517 ! DIMENSION: Scalar
518 ! ATTRIBUTES: INTENT(IN OUT)
519 !
520 ! GeometryInfo: CRTM_GeometryInfo structure containing the
521 ! view geometry information.
522 ! UNITS: N/A
523 ! TYPE: TYPE(CRTM_GeometryInfo_type)
524 ! DIMENSION: Scalar
525 ! ATTRIBUTES: INTENT(IN)
526 !
527 ! SensorIndex: Sensor index id. This is a unique index associated
528 ! with a (supported) sensor used to access the
529 ! shared coefficient data for a particular sensor.
530 ! See the ChannelIndex argument.
531 ! UNITS: N/A
532 ! TYPE: INTEGER
533 ! DIMENSION: Scalar
534 ! ATTRIBUTES: INTENT(IN)
535 !
536 ! ChannelIndex: Channel index id. This is a unique index associated
537 ! with a (supported) sensor channel used to access the
538 ! shared coefficient data for a particular sensor's
539 ! channel.
540 ! See the SensorIndex argument.
541 ! UNITS: N/A
542 ! TYPE: INTEGER
543 ! DIMENSION: Scalar
544 ! ATTRIBUTES: INTENT(IN)
545 !
546 ! iVar: Structure containing internal variables required for
547 ! subsequent tangent-linear or adjoint model calls.
548 ! The contents of this structure are NOT accessible
549 ! outside of the CRTM_MW_Water_SfcOptics module.
550 ! UNITS: N/A
551 ! TYPE: iVar_type
552 ! DIMENSION: Scalar
553 ! ATTRIBUTES: INTENT(IN)
554 !
555 ! OUTPUT ARGUMENTS:
556 ! Surface_AD: CRTM_Surface structure containing the adjoint
557 ! surface state data.
558 ! UNITS: N/A
559 ! TYPE: TYPE(CRTM_Surface_type)
560 ! DIMENSION: Scalar
561 ! ATTRIBUTES: INTENT(IN OUT)
562 !
563 ! FUNCTION RESULT:
564 ! Error_Status: The return value is an integer defining the error status.
565 ! The error codes are defined in the Message_Handler module.
566 ! If == SUCCESS the computation was sucessful
567 ! == FAILURE an unrecoverable error occurred
568 ! UNITS: N/A
569 ! TYPE: INTEGER
570 ! DIMENSION: Scalar
571 !
572 ! COMMENTS:
573 ! Note the INTENT on the input SfcOptics_AD argument is IN OUT rather
574 ! than just OUT. This is necessary because components of this argument
575 ! may need to be zeroed out upon output.
576 !
577 ! Note the INTENT on the output Surface_AD argument is IN OUT rather
578 ! than just OUT. This is necessary because the argument may be defined
579 ! upon input. To prevent memory leaks, the IN OUT INTENT is a must.
580 !
581 !----------------------------------------------------------------------------------
582 
584  SfcOptics , & ! Input
585  SfcOptics_AD, & ! Input
586  GeometryInfo, & ! Input
587  SensorIndex , & ! Input
588  ChannelIndex, & ! Input
589  Surface_AD , & ! Output
590  iVar ) & ! Internal variable input
591  result( err_stat )
592  ! Arguments
593  TYPE(crtm_sfcoptics_type), INTENT(IN) :: sfcoptics
594  TYPE(crtm_sfcoptics_type), INTENT(IN OUT) :: sfcoptics_ad
595  TYPE(crtm_geometryinfo_type), INTENT(IN) :: geometryinfo
596  INTEGER, INTENT(IN) :: sensorindex
597  INTEGER, INTENT(IN) :: channelindex
598  TYPE(crtm_surface_type), INTENT(IN OUT) :: surface_ad
599  TYPE(ivar_type), INTENT(IN) :: ivar
600  ! Function result
601  INTEGER :: err_stat
602  ! Local parameters
603  CHARACTER(*), PARAMETER :: routine_name = 'Compute_MW_Water_SfcOptics_AD'
604  ! Local variables
605  INTEGER :: i, j
606  REAL(fp) :: frequency
607  REAL(fp) :: source_azimuth_angle, sensor_azimuth_angle
608  REAL(fp) :: reflectivity_ad(n_stokes)
609  REAL(fp) :: azimuth_angle_ad
610 
611 
612  ! Set up
613  err_stat = success
614  ! ...Retrieve data from structures
615  frequency = sc(sensorindex)%Frequency(channelindex)
617  geometryinfo, &
618  source_azimuth_angle = source_azimuth_angle, &
619  sensor_azimuth_angle = sensor_azimuth_angle )
620 
621 
622  ! Compute the adjoint surface optical parameters
623  IF( sfcoptics%Use_New_MWSSEM ) THEN
624 
625  ! FastemX model
626  azimuth_angle_ad = zero
627  DO i = 1, sfcoptics%n_Angles
628  DO j = 1, n_stokes
629  reflectivity_ad(j) = sfcoptics_ad%Reflectivity(i,j,i,j)
630  END DO
631  CALL compute_fastemx_ad( &
632  mwwaterc , & ! Input model coefficients
633  sfcoptics_ad%Emissivity(i,:) , & ! AD Input
634  reflectivity_ad , & ! AD Input
635  ivar%FastemX_Var , & ! Internal variable input
636  surface_ad%Water_Temperature , & ! AD Output
637  surface_ad%Salinity , & ! AD Output
638  surface_ad%Wind_Speed , & ! AD Output
639  azimuth_angle_ad = azimuth_angle_ad , & ! Optional AD Output
640  transmittance_ad = sfcoptics_ad%Transmittance ) ! Optional AD Output
641  END DO
642  surface_ad%Wind_Direction = surface_ad%Wind_Direction + azimuth_angle_ad
643 
644  ELSE
645 
646  ! Low frequency model coupled with Fastem1
647  IF( frequency < low_f_threshold ) THEN
648  ! Call the low frequency model
649  DO i = 1, sfcoptics%n_Angles
650  sfcoptics_ad%Emissivity(i,1) = sfcoptics_ad%Emissivity(i,1)-sfcoptics_ad%Reflectivity(i,1,i,1)
651  sfcoptics_ad%Emissivity(i,2) = sfcoptics_ad%Emissivity(i,2)-sfcoptics_ad%Reflectivity(i,2,i,2)
652  CALL lowfrequency_mwssem_ad( &
653  sfcoptics_ad%Emissivity(i,:), & ! AD Input
654  surface_ad%Water_Temperature, & ! AD Output
655  surface_ad%Salinity , & ! AD Output
656  surface_ad%Wind_Speed , & ! AD Output
657  ivar%LF_MWSSEM_Var ) ! Internal variable input
658  END DO
659  ELSE
660  ! Call Fastem1
661  DO i = sfcoptics%n_Angles, 1, -1
662  DO j = 1, 2
663  sfcoptics_ad%Emissivity(i,j) = sfcoptics_ad%Emissivity(i,j) - &
664  sfcoptics_ad%Reflectivity(i,j,i,j)
665  sfcoptics_ad%Reflectivity(i,j,i,j) = zero
666  END DO
667  ! Vertical polarisation component
668  surface_ad%Water_Temperature = surface_ad%Water_Temperature + &
669  (ivar%dEV_dTs(i)*sfcoptics_ad%Emissivity(i,1))
670  surface_ad%Wind_Speed = surface_ad%Wind_Speed + &
671  (ivar%dEV_dWindSpeed(i)*sfcoptics_ad%Emissivity(i,1))
672  sfcoptics_ad%Emissivity(i,1) = zero
673  ! Horizontal polarization component
674  surface_ad%Water_Temperature = surface_ad%Water_Temperature + &
675  (ivar%dEH_dTs(i)*sfcoptics_ad%Emissivity(i,2))
676  surface_ad%Wind_Speed = surface_ad%Wind_Speed + &
677  (ivar%dEH_dWindSpeed(i)*sfcoptics_ad%Emissivity(i,2))
678  sfcoptics_ad%Emissivity(i,2) = zero
679  END DO
680  END IF
681  END IF
682 
683  sfcoptics_ad%Reflectivity = zero
684 
685  END FUNCTION compute_mw_water_sfcoptics_ad
686 
687 END MODULE crtm_mw_water_sfcoptics
character(*), parameter module_version_id
integer, parameter, public set
real(fp), parameter, public zero
subroutine, public compute_fastemx_tl(MWwaterCoeff, Temperature_TL, Salinity_TL, Wind_Speed_TL, iVar, Emissivity_TL, Reflectivity_TL, Azimuth_Angle_TL, Transmittance_TL)
type(mwwatercoeff_type), target, save, public mwwaterc
integer, parameter, public fp
Definition: Type_Kinds.f90:124
integer, parameter, public max_n_angles
integer function, public compute_mw_water_sfcoptics_tl(SfcOptics, Surface_TL, GeometryInfo, SensorIndex, ChannelIndex, SfcOptics_TL, iVar)
integer function, public compute_mw_water_sfcoptics(Surface, GeometryInfo, SensorIndex, ChannelIndex, SfcOptics, iVar)
integer function, public compute_mw_water_sfcoptics_ad(SfcOptics, SfcOptics_AD, GeometryInfo, SensorIndex, ChannelIndex, Surface_AD, iVar)
subroutine, public lowfrequency_mwssem_ad(Emissivity_AD, Temperature_AD, Salinity_AD, Wind_Speed_AD, iVar)
integer, parameter, public max_n_stokes
subroutine, public fastem1(Frequency, Sat_Zenith_Angle, SST, Wind_Speed, Emissivity, dEH_dWindSpeed, dEV_dWindSpeed)
integer, parameter, public not_set
real(fp), parameter, public one
real(fp), parameter low_f_threshold
subroutine, public compute_fastemx_ad(MWwaterCoeff, Emissivity_AD, Reflectivity_AD, iVar, Temperature_AD, Salinity_AD, Wind_Speed_AD, Azimuth_Angle_AD, Transmittance_AD)
subroutine, public lowfrequency_mwssem(Frequency, Zenith_Angle, Temperature, Salinity, Wind_Speed, Emissivity, iVar)
subroutine, public lowfrequency_mwssem_tl(Temperature_TL, Salinity_TL, Wind_Speed_TL, Emissivity_TL, iVar)
type(spccoeff_type), dimension(:), allocatable, save, public sc
subroutine, public compute_fastemx(MWwaterCoeff, Frequency, Zenith_Angle, Temperature, Salinity, Wind_Speed, iVar, Emissivity, Reflectivity, Azimuth_Angle, Transmittance)
integer, parameter, public success
elemental subroutine, public crtm_geometryinfo_getvalue(gInfo, Geometry, iFOV, Longitude, Latitude, Surface_Altitude, Sensor_Scan_Angle, Sensor_Zenith_Angle, Sensor_Azimuth_Angle, Source_Zenith_Angle, Source_Azimuth_Angle, Flux_Zenith_Angle, Year, Month, Day, Distance_Ratio, Sensor_Scan_Radian, Sensor_Zenith_Radian, Sensor_Azimuth_Radian, Secant_Sensor_Zenith, Cosine_Sensor_Zenith, Source_Zenith_Radian, Source_Azimuth_Radian, Secant_Source_Zenith, Flux_Zenith_Radian, Secant_Flux_Zenith, Trans_Zenith_Radian, Secant_Trans_Zenith, AU_ratio2)