Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ fix/
**/Build/
build.bash
rebuild.bash
conductor/
.gitignore
*~
122 changes: 93 additions & 29 deletions src/CRTM_LifeCycle.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ MODULE CRTM_LifeCycle
! -----------------
! Module usage
USE Message_Handler
USE File_Utility, ONLY: File_Exists
USE CRTM_ChannelInfo_Define, ONLY: CRTM_ChannelInfo_type, &
CRTM_ChannelInfo_Associated, &
CRTM_ChannelInfo_Destroy, &
Expand Down Expand Up @@ -630,6 +631,7 @@ FUNCTION CRTM_Init( &
CHARACTER(SL) :: Default_VISsnowCoeff_Format
CHARACTER(SL) :: Default_VISiceCoeff_Format
CHARACTER(SL) :: Default_File_Path
CHARACTER(SL) :: fname_nc, fname_bin


INTEGER :: l, n, n_Sensors
Expand Down Expand Up @@ -680,33 +682,33 @@ FUNCTION CRTM_Init( &
Default_File_Path = ''
! ...Default filenames
Default_Aerosol_Model = 'CRTM'
Default_AerosolCoeff_File = 'AerosolCoeff.bin'
Default_AerosolCoeff_File = 'AerosolCoeff.nc4'
Default_Cloud_Model = 'CRTM'
Default_CloudCoeff_File = 'CloudCoeff.bin'
Default_IRwaterCoeff_File = 'Nalli.IRwater.EmisCoeff.bin'
Default_IRlandCoeff_File = 'NPOESS.IRland.EmisCoeff.bin'
Default_CloudCoeff_File = 'CloudCoeff.nc4'
Default_IRwaterCoeff_File = 'Nalli.IRwater.EmisCoeff.nc4'
Default_IRlandCoeff_File = 'NPOESS.IRland.EmisCoeff.nc4'
Default_IRsnow_Model = 'SEcategory'
Default_IRsnowCoeff_File = 'NPOESS.IRsnow.EmisCoeff.bin'
Default_IRiceCoeff_File = 'NPOESS.IRice.EmisCoeff.bin'
Default_VISwaterCoeff_File = 'NPOESS.VISwater.EmisCoeff.bin'
Default_VISlandCoeff_File = 'NPOESS.VISland.EmisCoeff.bin'
Default_VISsnowCoeff_File = 'NPOESS.VISsnow.EmisCoeff.bin'
Default_VISiceCoeff_File = 'NPOESS.VISice.EmisCoeff.bin'
Default_IRsnowCoeff_File = 'NPOESS.IRsnow.EmisCoeff.nc4'
Default_IRiceCoeff_File = 'NPOESS.IRice.EmisCoeff.nc4'
Default_VISwaterCoeff_File = 'NPOESS.VISwater.EmisCoeff.nc4'
Default_VISlandCoeff_File = 'NPOESS.VISland.EmisCoeff.nc4'
Default_VISsnowCoeff_File = 'NPOESS.VISsnow.EmisCoeff.nc4'
Default_VISiceCoeff_File = 'NPOESS.VISice.EmisCoeff.nc4'
Default_MWwaterCoeff_File = 'FASTEM6.MWwater.EmisCoeff.bin'
Default_MWwaterCoeff_Scheme = 'FASTEM6'
! ... Default file formats
Default_AerosolCoeff_Format = 'Binary'
Default_CloudCoeff_Format = 'Binary'
Default_SpcCoeff_Format = 'Binary'
Default_TauCoeff_Format = 'Binary'
Default_IRwaterCoeff_Format = 'Binary'
Default_IRlandCoeff_Format = 'Binary'
Default_IRsnowCoeff_Format = 'Binary'
Default_IRiceCoeff_Format = 'Binary'
Default_VISwaterCoeff_Format= 'Binary'
Default_VISlandCoeff_Format = 'Binary'
Default_VISsnowCoeff_Format = 'Binary'
Default_VISiceCoeff_Format = 'Binary'
Default_AerosolCoeff_Format = 'netCDF'
Default_CloudCoeff_Format = 'netCDF'
Default_SpcCoeff_Format = 'netCDF'
Default_TauCoeff_Format = 'netCDF'
Default_IRwaterCoeff_Format = 'netCDF'
Default_IRlandCoeff_Format = 'netCDF'
Default_IRsnowCoeff_Format = 'netCDF'
Default_IRiceCoeff_Format = 'netCDF'
Default_VISwaterCoeff_Format= 'netCDF'
Default_VISlandCoeff_Format = 'netCDF'
Default_VISsnowCoeff_Format = 'netCDF'
Default_VISiceCoeff_Format = 'netCDF'
! ...Were coefficient models specified?
IF ( PRESENT(Aerosol_Model ) ) Default_Aerosol_Model = TRIM(ADJUSTL(Aerosol_Model))
IF ( PRESENT(Cloud_Model ) ) Default_Cloud_Model = TRIM(ADJUSTL(Cloud_Model))
Expand Down Expand Up @@ -744,6 +746,40 @@ FUNCTION CRTM_Init( &
Default_MWwaterCoeff_File = TRIM(ADJUSTL(File_Path)) // TRIM(Default_MWwaterCoeff_File)
END IF

! Smart detect SpcCoeff format if not specified
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be adopted for all LUTs, to get ride of format specification.

IF ( .NOT. PRESENT(SpcCoeff_Format) .AND. SIZE(Sensor_ID) > 0 ) THEN
fname_nc = TRIM(ADJUSTL(Sensor_ID(1))) // '.SpcCoeff.nc'
fname_bin = TRIM(ADJUSTL(Sensor_ID(1))) // '.SpcCoeff.bin'
IF ( PRESENT(File_Path) ) THEN
IF ( LEN_TRIM(File_Path) > 0 ) THEN
fname_nc = TRIM(File_Path) // fname_nc
fname_bin = TRIM(File_Path) // fname_bin
END IF
END IF
IF ( File_Exists(fname_nc) ) THEN
Default_SpcCoeff_Format = 'netCDF'
ELSE IF ( File_Exists(fname_bin) ) THEN
Default_SpcCoeff_Format = 'Binary'
END IF
END IF

! Smart detect TauCoeff format if not specified
IF ( .NOT. PRESENT(TauCoeff_Format) .AND. SIZE(Sensor_ID) > 0 ) THEN
fname_nc = TRIM(ADJUSTL(Sensor_ID(1))) // '.TauCoeff.nc'
fname_bin = TRIM(ADJUSTL(Sensor_ID(1))) // '.TauCoeff.bin'
IF ( PRESENT(File_Path) ) THEN
IF ( LEN_TRIM(File_Path) > 0 ) THEN
fname_nc = TRIM(File_Path) // fname_nc
fname_bin = TRIM(File_Path) // fname_bin
END IF
END IF
IF ( File_Exists(fname_nc) ) THEN
Default_TauCoeff_Format = 'netCDF'
ELSE IF ( File_Exists(fname_bin) ) THEN
Default_TauCoeff_Format = 'Binary'
END IF
END IF

! Load the spectral coefficients
netCDF = .FALSE.
IF (Default_SpcCoeff_Format == 'netCDF' ) THEN
Expand Down Expand Up @@ -790,7 +826,11 @@ FUNCTION CRTM_Init( &
IF ( Local_Load_CloudCoeff ) THEN
IF ( Default_CloudCoeff_Format == 'netCDF' ) THEN
netCDF = .TRUE.
IF ( PRESENT(NC_File_Path) ) Default_File_Path = NC_File_Path
IF ( PRESENT(NC_File_Path) ) THEN
Default_File_Path = NC_File_Path
ELSEIF ( PRESENT(File_Path) ) THEN
Default_File_Path = File_Path
END IF
ELSE
netCDF = .FALSE.
IF ( PRESENT(File_Path) ) Default_File_Path = File_Path
Expand Down Expand Up @@ -819,7 +859,11 @@ FUNCTION CRTM_Init( &
IF ( Local_Load_AerosolCoeff ) THEN
IF ( Default_AerosolCoeff_Format == 'netCDF' ) THEN
netCDF = .TRUE.
IF ( PRESENT(NC_File_Path) ) Default_File_Path = NC_File_Path
IF ( PRESENT(NC_File_Path) ) THEN
Default_File_Path = NC_File_Path
ELSEIF ( PRESENT(File_Path) ) THEN
Default_File_Path = File_Path
END IF
ELSE
netCDF = .FALSE.
IF ( PRESENT(File_Path) ) Default_File_Path = File_Path
Expand Down Expand Up @@ -849,7 +893,11 @@ FUNCTION CRTM_Init( &
! ...IR land
IF ( Default_IRlandCoeff_Format == 'netCDF' ) THEN
netCDF = .TRUE.
IF ( PRESENT(NC_File_Path) ) Default_File_Path = NC_File_Path
IF ( PRESENT(NC_File_Path) ) THEN
Default_File_Path = NC_File_Path
ELSEIF ( PRESENT(File_Path) ) THEN
Default_File_Path = File_Path
END IF
ELSE
netCDF = .FALSE.
IF ( PRESENT(File_Path) ) Default_File_Path = File_Path
Expand All @@ -872,7 +920,11 @@ FUNCTION CRTM_Init( &
! ...IR Water
IF ( Default_IRwaterCoeff_Format == 'netCDF' ) THEN
netCDF = .TRUE.
IF ( PRESENT(NC_File_Path) ) Default_File_Path = NC_File_Path
IF ( PRESENT(NC_File_Path) ) THEN
Default_File_Path = NC_File_Path
ELSEIF ( PRESENT(File_Path) ) THEN
Default_File_Path = File_Path
END IF
ELSE
netCDF = .FALSE.
IF ( PRESENT(File_Path) ) Default_File_Path = File_Path
Expand All @@ -895,7 +947,11 @@ FUNCTION CRTM_Init( &
! ...IR snow
IF ( Default_IRsnowCoeff_Format == 'netCDF' ) THEN
netCDF = .TRUE.
IF ( PRESENT(NC_File_Path) ) Default_File_Path = NC_File_Path
IF ( PRESENT(NC_File_Path) ) THEN
Default_File_Path = NC_File_Path
ELSEIF ( PRESENT(File_Path) ) THEN
Default_File_Path = File_Path
END IF
ELSE
netCDF = .FALSE.
IF ( PRESENT(File_Path) ) Default_File_Path = File_Path
Expand Down Expand Up @@ -924,7 +980,11 @@ FUNCTION CRTM_Init( &
! ...IR ice
IF ( Default_IRiceCoeff_Format == 'netCDF' ) THEN
netCDF = .TRUE.
IF ( PRESENT(NC_File_Path) ) Default_File_Path = NC_File_Path
IF ( PRESENT(NC_File_Path) ) THEN
Default_File_Path = NC_File_Path
ELSEIF ( PRESENT(File_Path) ) THEN
Default_File_Path = File_Path
END IF
ELSE
netCDF = .FALSE.
IF ( PRESENT(File_Path) ) Default_File_Path = File_Path
Expand All @@ -951,7 +1011,11 @@ FUNCTION CRTM_Init( &
! ...VIS land
IF ( Default_VISlandCoeff_Format == 'netCDF' ) THEN
netCDF = .TRUE.
IF ( PRESENT(NC_File_Path) ) Default_File_Path = NC_File_Path
IF ( PRESENT(NC_File_Path) ) THEN
Default_File_Path = NC_File_Path
ELSEIF ( PRESENT(File_Path) ) THEN
Default_File_Path = File_Path
END IF
ELSE
netCDF = .FALSE.
IF ( PRESENT(File_Path) ) Default_File_Path = File_Path
Expand Down
30 changes: 15 additions & 15 deletions src/Coefficients/ACCoeff/ACCoeff_IO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ MODULE ACCoeff_IO
! OPTIONAL INPUTS:
! netCDF: Set this logical argument to access netCDF format
! ACCoeff datafiles.
! If == .FALSE., file format is BINARY [DEFAULT].
! == .TRUE., file format is NETCDF.
! If not specified, default is .FALSE.
! If == .FALSE., file format is BINARY.
! == .TRUE., file format is NETCDF [DEFAULT].
! If not specified, default is .TRUE.
! UNITS: N/A
! TYPE: LOGICAL
! DIMENSION: Scalar
Expand Down Expand Up @@ -213,17 +213,17 @@ FUNCTION ACCoeff_InquireFile( &
! Function result
INTEGER :: err_stat
! Function variables
LOGICAL :: binary
LOGICAL :: Binary

! Set up
err_stat = SUCCESS
! ...Check netCDF argument
binary = .TRUE.
IF ( PRESENT(netCDF) ) binary = .NOT. netCDF
Binary = .FALSE.
IF ( PRESENT(netCDF) ) Binary = .NOT. netCDF


! Call the appropriate function
IF ( binary ) THEN
IF ( Binary ) THEN
err_stat = ACCoeff_Binary_InquireFile( &
Filename, &
n_FOVs = n_FOVs , &
Expand Down Expand Up @@ -367,16 +367,16 @@ FUNCTION ACCoeff_ReadFile( &
! Function result
INTEGER :: err_stat
! Function variables
LOGICAL :: binary
LOGICAL :: Binary

! Set up
err_stat = SUCCESS
! ...Check netCDF argument
binary = .TRUE.
IF ( PRESENT(netCDF) ) binary = .NOT. netCDF
Binary = .FALSE.
IF ( PRESENT(netCDF) ) Binary = .NOT. netCDF

! Call the appropriate function
IF ( binary ) THEN
IF ( Binary ) THEN
err_stat = ACCoeff_Binary_ReadFile( &
Filename, &
ACCoeff , &
Expand Down Expand Up @@ -508,16 +508,16 @@ FUNCTION ACCoeff_WriteFile( &
! Function result
INTEGER :: err_stat
! Local variables
LOGICAL :: binary
LOGICAL :: Binary

! Set up
err_stat = SUCCESS
! ...Check netCDF argument
binary = .TRUE.
IF ( PRESENT(netCDF) ) binary = .NOT. netCDF
Binary = .FALSE.
IF ( PRESENT(netCDF) ) Binary = .NOT. netCDF

! Call the appropriate function
IF ( binary ) THEN
IF ( Binary ) THEN
err_stat = ACCoeff_Binary_WriteFile( &
Filename, &
ACCoeff , &
Expand Down
12 changes: 6 additions & 6 deletions src/Coefficients/AerosolCoeff/AerosolCoeff_IO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ MODULE AerosolCoeff_IO
! OPTIONAL INPUTS:
! netCDF: Set this logical argument to access netCDF format
! AerosolCoeff datafiles.
! If == .FALSE., file format is BINARY [DEFAULT].
! == .TRUE., file format is NETCDF.
! If not specified, default is .FALSE.
! If == .FALSE., file format is BINARY.
! == .TRUE., file format is NETCDF [DEFAULT].
! If not specified, default is .TRUE.
! UNITS: N/A
! TYPE: LOGICAL
! DIMENSION: Scalar
Expand Down Expand Up @@ -255,7 +255,7 @@ FUNCTION AerosolCoeff_InquireFile( &
! Set up
err_stat = SUCCESS
! ...Check netCDF argument
Binary = .TRUE.
Binary = .FALSE.
IF ( PRESENT(netCDF) ) Binary = .NOT. netCDF


Expand Down Expand Up @@ -430,7 +430,7 @@ FUNCTION AerosolCoeff_ReadFile( &
! Set up
err_stat = SUCCESS
! ...Check netCDF argument
Binary = .TRUE.
Binary = .FALSE.
IF ( PRESENT(netCDF) ) Binary = .NOT. netCDF

! Call the appropriate function
Expand Down Expand Up @@ -586,7 +586,7 @@ FUNCTION AerosolCoeff_WriteFile( &
! Set up
err_stat = SUCCESS
! ...Check netCDF argument
Binary = .TRUE.
Binary = .FALSE.
IF ( PRESENT(netCDF) ) Binary = .NOT. netCDF

! Call the appropriate function
Expand Down
12 changes: 6 additions & 6 deletions src/Coefficients/CloudCoeff/CloudCoeff_IO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ MODULE CloudCoeff_IO
! OPTIONAL INPUTS:
! netCDF: Set this logical argument to access netCDF format
! CloudCoeff datafiles.
! If == .FALSE., file format is BINARY [DEFAULT].
! == .TRUE., file format is NETCDF.
! If not specified, default is .FALSE.
! If == .FALSE., file format is BINARY.
! == .TRUE., file format is NETCDF [DEFAULT].
! If not specified, default is .TRUE.
! UNITS: N/A
! TYPE: LOGICAL
! DIMENSION: Scalar
Expand Down Expand Up @@ -262,7 +262,7 @@ FUNCTION CloudCoeff_InquireFile( &
! Set up
err_stat = SUCCESS
! ...Check netCDF argument
Binary = .TRUE.
Binary = .FALSE.
IF ( PRESENT(netCDF) ) Binary = .NOT. netCDF


Expand Down Expand Up @@ -423,7 +423,7 @@ FUNCTION CloudCoeff_ReadFile( &
! Set up
err_stat = SUCCESS
! ...Check netCDF argument
Binary = .TRUE.
Binary = .FALSE.
IF ( PRESENT(netCDF) ) Binary = .NOT. netCDF

! Call the appropriate function
Expand Down Expand Up @@ -563,7 +563,7 @@ FUNCTION CloudCoeff_WriteFile( &
! Set up
err_stat = SUCCESS
! ...Check netCDF argument
Binary = .TRUE.
Binary = .FALSE.
IF ( PRESENT(netCDF) ) Binary = .NOT. netCDF

! Call the appropriate function
Expand Down
Loading