76 '$Id: CRTM_TauCoeff.f90 60152 2015-08-13 19:19:13Z paul.vandelst@noaa.gov $' 191 File_Path , & ! Optional input
192 Quiet , & ! Optional input
193 Process_ID , & ! Optional input
194 Output_Process_ID, & ! Optional input
196 result( error_status )
199 CHARACTER(*),
DIMENSION(:),
OPTIONAL,
INTENT(IN) :: sensor_id
200 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: file_path
201 INTEGER,
OPTIONAL,
INTENT(IN) :: quiet
202 INTEGER,
OPTIONAL,
INTENT(IN) :: process_id
203 INTEGER,
OPTIONAL,
INTENT(IN) :: output_process_id
204 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: message_log
206 INTEGER :: error_status
208 CHARACTER(*),
PARAMETER :: routine_name =
'CRTM_Load_TauCoeff' 210 CHARACTER(256) :: message
211 CHARACTER(256) :: process_id_tag
212 CHARACTER(256) :: local_path
213 CHARACTER(256),
DIMENSION(MAX_N_SENSORS) :: taucoeff_file
214 INTEGER :: allocate_status, deallocate_status
215 INTEGER :: n, n_sensors
217 INTEGER,
PARAMETER :: sl = 128
218 INTEGER :: algorithm_id
219 CHARACTER(SL),
ALLOCATABLE :: sensorids(:)
220 CHARACTER(SL),
ALLOCATABLE :: zfnames(:)
221 INTEGER,
ALLOCATABLE :: sensorindex(:)
227 IF (
PRESENT(file_path) ) local_path = trim(adjustl(file_path))
230 IF (
PRESENT(process_id) )
THEN 231 WRITE( process_id_tag,
'("; MPI Process ID: ",i0)' ) process_id
237 IF (
PRESENT(sensor_id) )
THEN 240 n_sensors =
SIZE(sensor_id)
243 WRITE(message,
'("Too many sensors, ",i0," specified. Maximum of ",i0," sensors allowed.")') &
246 trim(message)//trim(process_id_tag), &
248 message_log=message_log)
252 taucoeff_file(n) = trim(adjustl(sensor_id(n)))//
'.TauCoeff.bin' 257 taucoeff_file(1) =
'TauCoeff.bin' 262 taucoeff_file(n) = trim(local_path)//trim(taucoeff_file(n))
266 tc%n_Sensors = n_sensors
270 ALLOCATE( sensorids( n_sensors ), &
271 zfnames( n_sensors ), &
272 sensorindex( n_sensors ), &
273 stat = allocate_status )
274 IF ( allocate_status /= 0 )
THEN 276 WRITE( message,
'( "Error allocating local arrays with an n_Sensors dimension. STAT = ", i5 )' ) &
281 message_log = message_log )
286 IF ( error_status /=
success )
THEN 287 message =
'Error creating TC' 295 sensor_loop:
DO n = 1, n_sensors
298 tc%Sensor_Index(n) = n
303 message_log = message_log )
304 IF ( error_status /=
success )
THEN 306 'cannot obtain transmittance algorithm ID from file '//&
307 trim( taucoeff_file(n) )//trim( process_id_tag ), &
309 message_log = message_log )
313 tc%Algorithm_ID(n) = algorithm_id
316 SELECT CASE( algorithm_id )
317 CASE ( odas_algorithm )
319 tc%n_ODAS =
tc%n_ODAS + 1
321 tc%Sensor_LoIndex(n) =
tc%n_ODAS
323 CASE ( odps_algorithm )
325 tc%n_ODPS =
tc%n_ODPS + 1
327 tc%Sensor_LoIndex(n) =
tc%n_ODPS
329 CASE ( odssu_algorithm )
331 tc%n_ODSSU =
tc%n_ODSSU + 1
333 tc%Sensor_LoIndex(n) =
tc%n_ODSSU
339 IF(algorithm_id==10)
THEN 340 message=
'The algorithm ID does not exist, TauCoeff file need to be converted to new format' 342 WRITE( message,
'( "The algorithm ID = ", i5, " does not exist ")' ) &
347 trim( message )//trim( process_id_tag ), &
349 message_log = message_log )
365 IF (
PRESENT(sensor_id) )
THEN 367 sensorids, sensorindex, &
368 sensorid_in = sensor_id )
369 error_status = odas_load_taucoeff( &
370 sensor_id =sensorids(1:n) , &
371 file_path =file_path , &
373 process_id =process_id , &
374 output_process_id=output_process_id, &
375 message_log =message_log )
378 error_status = odas_load_taucoeff( &
379 file_path =file_path , &
381 process_id =process_id , &
382 output_process_id=output_process_id, &
383 message_log =message_log )
386 IF ( error_status /=
success )
THEN 388 'Error loading ODAS TauCoeff data', &
390 message_log=message_log )
400 tc%Sensor_ID(j) =
tc%ODAS(i)%Sensor_ID
401 tc%WMO_Satellite_ID(j) =
tc%ODAS(i)%WMO_Satellite_ID
402 tc%WMO_Sensor_ID(j) =
tc%ODAS(i)%WMO_Sensor_ID
403 tc%Sensor_Type(j) =
tc%ODAS(i)%Sensor_Type
412 IF (
PRESENT(sensor_id) )
THEN 414 sensorids, sensorindex, &
415 sensorid_in = sensor_id )
416 error_status = odps_load_taucoeff( &
417 sensor_id =sensorids(1:n) , &
418 file_path =file_path , &
420 process_id =process_id , &
421 output_process_id=output_process_id, &
422 message_log =message_log )
425 error_status = odps_load_taucoeff( &
426 file_path =file_path , &
428 process_id =process_id , &
429 output_process_id=output_process_id, &
430 message_log =message_log )
433 IF ( error_status /=
success )
THEN 435 'Error loading ODPS TauCoeff data', &
437 message_log=message_log )
447 tc%Sensor_ID(j) =
tc%ODPS(i)%Sensor_ID
448 tc%WMO_Satellite_ID(j) =
tc%ODPS(i)%WMO_Satellite_ID
449 tc%WMO_Sensor_ID(j) =
tc%ODPS(i)%WMO_Sensor_ID
450 tc%Sensor_Type(j) =
tc%ODPS(i)%Sensor_Type
459 IF (
PRESENT(sensor_id) )
THEN 461 sensorids, sensorindex, &
462 sensorid_in = sensor_id )
463 error_status = odssu_load_taucoeff( &
464 sensor_id =sensorids(1:n) , &
465 file_path =file_path , &
467 process_id =process_id , &
468 output_process_id=output_process_id, &
469 message_log =message_log )
472 error_status = odssu_load_taucoeff( &
473 file_path =file_path , &
475 process_id =process_id , &
476 output_process_id=output_process_id, &
477 message_log =message_log )
480 IF ( error_status /=
success )
THEN 482 'Error loading ODSSU TauCoeff data', &
484 message_log=message_log )
494 tc%Sensor_ID(j) =
tc%ODSSU(i)%Sensor_ID
495 tc%WMO_Satellite_ID(j) =
tc%ODSSU(i)%WMO_Satellite_ID
496 tc%WMO_Sensor_ID(j) =
tc%ODSSU(i)%WMO_Sensor_ID
497 tc%Sensor_Type(j) =
tc%ODSSU(i)%Sensor_Type
506 tc%ZSensor_LoIndex = 0
513 zfnames(i) =
'z'//trim(
tc%Sensor_ID(n))//
'.TauCoeff.bin' 514 IF(
file_exists(trim(local_path)//trim(zfnames(i))) )
THEN 515 tc%ZSensor_LoIndex(n) = i
521 IF(
tc%n_ODZeeman > 0 )
THEN 522 error_status = odzeeman_load_taucoeff( &
523 zfnames(1:
tc%n_ODZeeman) , &
524 file_path =file_path , &
526 process_id =process_id , &
527 output_process_id=output_process_id, &
528 message_log =message_log )
529 IF ( error_status /=
success )
THEN 531 'Error loading ODZeeman TauCoeff data', &
533 message_log=message_log )
536 tc%ODZeeman => odzeeman_tc
543 DEALLOCATE(sensorids, &
546 stat = deallocate_status)
547 IF ( deallocate_status /= 0 )
THEN 550 'Error deallocating the local arrays', &
552 message_log=message_log )
610 result( error_status )
613 INTEGER,
OPTIONAL,
INTENT(IN) :: process_id
614 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: message_log
616 INTEGER :: error_status
618 CHARACTER(*),
PARAMETER :: routine_name =
'CRTM_Destroy_TauCoeff' 620 CHARACTER(256) :: message
621 CHARACTER(256) :: process_id_tag
622 INTEGER :: destroy_status
628 IF (
PRESENT( process_id ) )
THEN 629 WRITE( process_id_tag,
'("; MPI Process ID: ",i0)' ) process_id
638 IF(
tc%n_ODAS > 0 )
THEN 644 destroy_status = odas_destroy_taucoeff( process_id =process_id , &
645 message_log=message_log )
646 IF ( destroy_status /=
success )
THEN 647 error_status = destroy_status
649 'Error deallocating shared TauCoeff_ODAS data structure', &
651 message_log=message_log )
658 IF(
tc%n_ODPS > 0 )
THEN 664 destroy_status = odps_destroy_taucoeff( process_id =process_id , &
665 message_log=message_log )
666 IF ( destroy_status /=
success )
THEN 667 error_status = destroy_status
669 'Error deallocating shared TauCoeff_ODPS data structure', &
671 message_log=message_log )
678 IF(
tc%n_ODSSU > 0 )
THEN 684 destroy_status = odssu_destroy_taucoeff( process_id =process_id , &
685 message_log=message_log )
686 IF ( destroy_status /=
success )
THEN 687 error_status = destroy_status
689 'Error deallocating shared TauCoeff_SSU data structure', &
691 message_log=message_log )
698 IF(
tc%n_ODZeeman > 0 )
THEN 701 NULLIFY(
tc%ODZeeman )
704 destroy_status = odzeeman_destroy_taucoeff( process_id =process_id , &
705 message_log=message_log )
706 IF ( destroy_status /=
success )
THEN 707 error_status = destroy_status
709 'Error deallocating shared TauCoeff Zeeman data structure', &
711 message_log=message_log )
720 IF ( error_status /=
success )
THEN 721 message =
'Error destroying TC' 729 Algorithm_ID , & ! Output
730 RCS_Id , & ! Revision control
732 result( error_status )
734 CHARACTER(*),
INTENT(IN) :: filename
735 INTEGER,
INTENT(OUT) :: algorithm_id
736 CHARACTER(*),
OPTIONAL,
INTENT(OUT) :: rcs_id
737 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: message_log
739 INTEGER :: error_status
741 CHARACTER(*),
PARAMETER :: routine_name =
'Inquire_AlgorithmID' 744 CHARACTER(256) :: message
747 INTEGER(Long) :: algorithm_id_in
748 INTEGER(Long) :: release_in
749 INTEGER(Long) :: version_in
759 message =
'File '//trim(filename)//
' not found.' 767 IF ( error_status /=
success )
THEN 768 message =
'Error opening TauCoeff Binary file '//trim(filename)
775 READ( fileid, iostat=io_status ) release_in, version_in
776 IF ( io_status /= 0 )
THEN 777 WRITE( message,
'("Error reading Release/Version values from ",a,& 778 &". IOSTAT = ",i0)' ) &
779 trim(filename), io_status
786 READ( fileid, iostat=io_status ) algorithm_id_in
787 IF ( io_status /= 0 )
THEN 788 WRITE( message,
'("Error reading Algorithm ID from ",a,& 789 &". IOSTAT = ",i0)' ) &
790 trim(filename), io_status
795 algorithm_id = algorithm_id_in
799 CLOSE( fileid, iostat=io_status )
800 IF ( io_status /= 0 )
THEN 801 WRITE( message,
'("Error closing ",a,". IOSTAT = ",i0)' ) &
802 trim(filename), io_status
809 INTEGER,
OPTIONAL,
INTENT(IN) :: Close_File
810 CHARACTER(256) :: Close_Message
812 IF (
PRESENT(close_file) )
THEN 813 IF ( close_file ==
set )
THEN 814 CLOSE( fileid, iostat=io_status )
815 IF ( io_status /= 0 )
THEN 816 WRITE( close_message,
'("; Error closing input file during error cleanup. IOSTAT=",i0)') &
818 message = trim(message)//trim(close_message)
827 message_log=message_log )
848 SensorID_subset, SensorIndex, & ! Output
850 INTEGER,
INTENT(IN) :: TheAlgorithmID
851 INTEGER,
INTENT(IN) :: AlgorithmID(:)
852 CHARACTER(*),
INTENT(OUT) :: SensorID_subset(:)
853 INTEGER,
INTENT(OUT) :: SensorIndex(:)
854 CHARACTER(*),
OPTIONAL,
INTENT(IN) :: SensorID_in(:)
859 IF(
PRESENT(sensorid_in))
THEN 861 DO i = 1,
SIZE(algorithmid)
862 IF(
tc%Algorithm_ID(i) == thealgorithmid)
THEN 864 sensorid_subset(ii) = sensorid_in(i)
integer, parameter, public failure
integer, parameter, public set
integer, parameter, public warning
subroutine, public taucoeff_create(self, n_Sensors, err_stat)
integer, parameter, public long
subroutine, public taucoeff_destroy(self, err_stat)
subroutine extract_sensorinfo(TheAlgorithmID, AlgorithmID, SensorID_subset, SensorIndex, SensorID_in)
integer, parameter, public wmo_ssmis
subroutine inquire_cleanup()
integer function inquire_algorithmid(Filename, Algorithm_ID, RCS_Id, Message_Log)
character(*), parameter module_rcs_id
integer function, public load_taucoeff(Sensor_ID, File_Path, Quiet, Process_ID, Output_Process_ID, Message_Log)
integer function, public open_binary_file(Filename, FileID, For_Output, No_Check)
recursive subroutine, public display_message(Routine_Name, Message, Error_State, Message_Log)
integer, parameter, public wmo_amsua
integer function, public destroy_taucoeff(Process_ID, Message_Log)
integer function, public crtm_load_taucoeff(Sensor_ID, File_Path, Quiet, Process_ID, Output_Process_ID, Message_Log)
type(taucoeff_type), save, public tc
integer, parameter, public success
integer function, public crtm_destroy_taucoeff(Process_ID, Message_Log)
integer, parameter, public max_n_sensors