56 integer,
parameter :: MAX_VAR_DIMS = 10
61 integer (kind = integer_fourbyte) :: i,j,k,l,m,n
64 integer (kind = integer_fourbyte) :: hdfstatus
65 integer (kind = integer_fourbyte ), &
66 dimension(MAX_VAR_DIMS) :: hdfstart, hdfstride, hdfedge
67 integer (kind = integer_fourbyte) :: sds_id, sds_index
69 integer (kind = integer_fourbyte),
parameter :: numsnowalbstatwaves = 10
70 integer (kind = integer_fourbyte),
parameter :: numecosystems = 18
71 integer (kind = integer_fourbyte),
parameter :: numsnowtypes = 2
73 real :: snowalbedostats (1:numsnowalbstatwaves, 0:numecosystems-1, &
78 integer (kind = integer_fourbyte),
parameter :: numseaicealbwaves = 8
79 real (kind =
single),
dimension(NumSeaIceAlbWaves) :: meltseaicealbedos, &
81 real (kind =
single),
dimension(set_albedo_bands) :: &
82 processmeltseaicealbedos, processdryseaicealbedos, transitionalbedo, &
85 real (kind =
single),
parameter :: percentageofdry = 0.800d0
86 real :: wavelength(10)
93 character (len = *),
intent(in ) :: snowalbedofn
94 character (len = *),
dimension(:),
intent(in ) :: wavelengthtext
96 real (kind =
single),
dimension(NumSnowAlbStatWaves) :: possstatwavelengths
97 real (kind =
single),
dimension(NumSeaIceAlbWaves) :: possseaicewavelengths
99 integer :: errorlevel, i, numalbwavesprocess
108 numecosystems, snowalbedostats, errorlevel )
117 possstatwavelengths(1) = 0.470000
118 possstatwavelengths(2) = 0.555000
119 possstatwavelengths(3) = 0.659000
120 possstatwavelengths(4) = 0.858000
121 possstatwavelengths(5) = 1.240000
122 possstatwavelengths(6) = 1.640000
123 possstatwavelengths(7) = 2.130000
124 possstatwavelengths(8) = 0.0
125 possstatwavelengths(9) = 0.0
126 possstatwavelengths(10) = 0.0
133 do i = 1, numalbwavesprocess
134 read( wavelengthtext(i), * ) wavelength(i)
137 processsnowalbstats= 0.
138 do i = 1, numalbwavesprocess-1
141 do j = 1, numsnowalbstatwaves-3
142 if ( mod(wavelength(i),possstatwavelengths(j)) < 0.05 )
then
143 processsnowalbstats(i,:,:) = snowalbedostats(j,:,:)
149 if (.not. foundwave)
then
156 processsnowalbstats(6,:,:) = processsnowalbstats(5,:,:)
157 print*,
'WDR NOTE both albedo and snow stats are cloned from 2.1 to 2.2 um'
160 processsnowalbstats(6,:,:) = processsnowalbstats(5,:,:) * 0.5000
168 possseaicewavelengths(1) = 0.470000
169 possseaicewavelengths(2) = 0.555000
170 possseaicewavelengths(3) = 0.659000
171 possseaicewavelengths(4) = 0.858000
172 possseaicewavelengths(5) = 1.240000
173 possseaicewavelengths(6) = 1.640000
174 possseaicewavelengths(7) = 2.130000
175 possseaicewavelengths(8) = 3.700000
179 dryseaicealbedos(1:7) = snowalbedostats(1:7,15,1)
180 meltseaicealbedos(1:7) = snowalbedostats(1:7,15,1) * percentageofdry
182 dryseaicealbedos(8) = dryseaicealbedos(7) * 0.5000d0
183 meltseaicealbedos(8) = meltseaicealbedos(7) * 0.5000d0
188 do i = 1, numalbwavesprocess
190 do j = 1, numseaicealbwaves
191 if ( mod(wavelength(i),possseaicewavelengths(j)) < 0.05 )
then
192 processdryseaicealbedos(i) = dryseaicealbedos(j)
193 processmeltseaicealbedos(i) = meltseaicealbedos(j)
199 if (.not. foundwave)
then
209 subroutine getalbedoeco (Lat, Long, JulianDay, EcosystemFN, &
210 emissivity_name, Debug, WavelengthText, ProcessLandAlbedo, &
211 icec, Albedo, emissivity, Ecosystem, Status, sfc_info )
276 real (kind =
single ),
dimension(:,:),
intent(in ) :: lat, long
277 character (len = *),
intent(in ) :: ecosystemfn
278 character (len = *),
intent(in ) :: emissivity_name
279 integer (kind = integer_fourbyte ),
intent(in ) :: julianday
280 logical,
intent(in ) :: debug
281 character (len = *),
dimension(:),
intent(in ) :: wavelengthtext
282 logical,
dimension(:),
intent(in ) :: processlandalbedo
283 real (kind =
single),
dimension(:,:),
intent(in ) :: icec
284 real (kind =
single ),
dimension(:,:,:),
intent(out) :: emissivity
285 integer*2,
dimension(:,:,:),
intent(out) :: albedo
286 integer*1,
dimension(:,:),
intent(out) :: ecosystem, sfc_info
287 integer (kind = integer_fourbyte),
intent(out) :: status
379 integer (kind = integer_fourbyte) :: numalbwavesprocess
381 integer (kind = integer_fourbyte) :: numberofcols, numberofrows
386 real (kind =
single) :: minlat, maxlat, minlong, maxlong
392 integer (kind = integer_fourbyte) :: nummapcols, nummaprows
393 integer (kind = integer_fourbyte) :: nummapcols_alb, nummaprows_alb
396 real (kind =
single) :: map_resolution
397 real (kind =
single) :: map_resolution_alb
400 real (kind =
single) :: westernmostlongitude, northernmostlatitude
401 real (kind =
single) :: westernmostlongitude_alb, northernmostlatitude_alb
404 integer (kind = integer_fourbyte) :: startx, stopx, starty, stopy, &
405 numberofxpoints, numberofypoints
406 integer (kind = integer_fourbyte) :: startx_alb, stopx_alb, &
407 starty_alb, stopy_alb
408 real (kind =
single) :: startxval, stopxval, startyval, stopyval
411 real (kind =
single ),
parameter :: scalefactor = 0.00100
413 INTEGER(integer_fourbyte),
allocatable,
DIMENSION(:,:) :: snowicetype
416 integer (kind = integer_onebyte),
allocatable,
dimension(:,:) :: ecosystemmap
418 integer (kind = integer_fourbyte) :: xindex, yindex
419 integer (kind = integer_fourbyte) :: xindex_alb, yindex_alb
422 integer (kind = integer_fourbyte) :: ecomapfid, albmapfid
424 integer (kind = integer_fourbyte) :: ecomapsdsid, albmapsdsid
426 character(len = MAX_SDS_NAME_LEN) :: sdsname
429 INTEGER(integer_fourbyte) :: errorlevel
433 LOGICAL :: arcticmeltingseason, wintertomelttransition, melttowintertransition
434 integer (kind = integer_fourbyte),
parameter :: transitiondays = 10, &
435 nhmeltbeg = 152, nhmeltend = 244, shmeltbeg = 334, shmeltend = 61
438 real (kind =
single),
parameter :: wateralbedo = 0.050000
439 real,
dimension(:),
allocatable :: albedo_real4
440 real,
parameter :: emissivity_fill = 0.985
443 real,
parameter :: emissivity_res = 0.05
444 integer,
parameter :: num_emiss_cols = 7200
445 integer,
parameter :: num_emiss_rows = 3600
446 real,
dimension(:,:,:),
allocatable :: emissivity_map
447 integer*2,
dimension(:,:),
allocatable :: emissivity_map_int
448 integer :: emiss_x, emiss_y
449 real :: emiss_west, emiss_north
451 integer :: file_id, var_id, err_code, start(2), stride(2), edge(2)
457 real,
dimension(2) :: min_geo_sav = (/ -9000., -9000. /), &
458 max_geo_sav = (/ -9000., -9000. /)
459 real :: geo_margin = 5.
465 numberofcols =
size( albedo(:,:,:), dim = 1 )
466 numberofrows =
size( albedo(:,:,:), dim = 2 )
467 numalbwavesprocess =
size( albedo(:,:,:), dim = 3 )
469 if( .not.
allocated( albedo_real4) ) &
470 allocate(albedo_real4(numalbwavesprocess))
474 if ( (numberofcols < 1) .or. &
475 (numberofrows < 1) .or. &
476 (numalbwavesprocess < 2) .or. &
477 (numecosystems < 1) )
then
480 'Problem with albedo array size, contact SDST',status,
'getAlbedoEco')
490 if (maxval(lat) == -999. .or. maxval(long) == -999.)
then
492 albedo(:,:,:) = -999.
493 emissivity(:,:,:) = -999.
496 minlat = minval( lat, &
497 mask = ( (lat >= -90.0000 .and. lat <= 90.00000) ) )
498 maxlat = maxval( lat, &
499 mask = ( (lat >= -90.0000 .and. lat <= 90.00000) ) )
500 minlong = minval( long, &
501 mask = ( (long >= -180.000 .and. long <= 180.0000) ) )
502 maxlong = maxval( long, &
503 mask = ( (long >= -180.000 .and. long <= 180.0000) ) )
508 if( ( minlat < min_geo_sav(1) ) .or. ( maxlat > max_geo_sav(1) ) .or. &
509 ( minlong < min_geo_sav(2) ) .or. ( maxlong > max_geo_sav(2) ) )
then
515 minlat = minlat - geo_margin
516 maxlat = maxlat + geo_margin
517 minlong = minlong - geo_margin
518 maxlong = maxlong + geo_margin
520 if( minlat < -90. ) minlat = -90.
521 if( maxlat > 90. ) maxlat = 90.
522 if( minlong < -180. ) minlong = -180.
523 if( maxlong > 180. ) maxlong = 180.
525 min_geo_sav(1) = minlat
526 min_geo_sav(2) = minlong
527 max_geo_sav(1) = maxlat
528 max_geo_sav(2) = maxlong
549 map_resolution = 360.000d0 / float(nummapcols)
552 westernmostlongitude = map_resolution / 2.0 - 180.0
553 northernmostlatitude = 90.0 - map_resolution / 2.0
564 startx = anint( (minlong-westernmostlongitude) / (map_resolution) ) + 1
565 stopx = anint( (maxlong-westernmostlongitude) / (map_resolution) ) + 1
566 starty = anint( (northernmostlatitude-maxlat ) / (map_resolution) ) + 1
567 stopy = anint( (northernmostlatitude-minlat ) / (map_resolution) ) + 1
571 if (startx == 0) startx = 1
572 if (stopx == nummapcols+1 ) stopx = nummapcols
573 if (starty == 0) starty = 1
574 if (stopy == nummaprows+1 ) stopy = nummaprows
577 numberofxpoints = stopx - startx + 1
578 numberofypoints = stopy - starty + 1
581 if ( (startx < 1) .or. (stopx > nummapcols) .or. &
582 (starty < 1) .or. (stopy > nummaprows) .or. &
583 (startx > stopx) .or. (starty > stopy) )
then
588 if (stopx > nummapcols) stopx = nummapcols
589 if (stopy > nummaprows) stopy = nummaprows
590 if (startx > stopx) startx = stopx-1
591 if (starty > stopy) starty = stopy-1
592 if (startx < 1) startx = 1
593 if (starty < 1) starty = 1
607 if(
allocated(ecosystemmap) )
deallocate( ecosystemmap )
608 allocate( ecosystemmap(startx:stopx, starty:stopy ) )
624 hdfedge(1) = numberofxpoints
625 hdfedge(2) = numberofypoints
631 sdsname =
"IGBP_Land_Cover_Type"
634 status = nf_open(
trim(ecosystemfn), nf_nowrite, ecomapfid )
635 if (ecomapfid == fail)
then
638 status,
'getAlbedoEco')
640 call cld_fchk( status, __file__, __line__ )
643 status = nf_inq_varid( ecomapfid,
trim(sdsname), ecomapsdsid )
644 if (ecomapsdsid == fail)
then
647 status,
'getAlbedoEco')
649 call cld_fchk( status, __file__, __line__ )
652 hdfstatus = nf_get_vara_int1( ecomapfid, ecomapsdsid, hdfstart, &
653 hdfedge, ecosystemmap )
655 if (hdfstatus == fail)
then
658 status,
'getAlbedoEco')
660 call cld_fchk( hdfstatus, __file__, __line__ )
662 hdfstatus = nf_close( ecomapfid )
663 if (hdfstatus == fail)
then
666 status,
'getAlbedoEco')
668 call cld_fchk( hdfstatus, __file__, __line__ )
675 emiss_west = emissivity_res / 2.0 - 180.0
676 emiss_north = 90.0 - emissivity_res / 2.0
680 startx = anint( (minlong-emiss_west) / (emissivity_res) ) + 1
681 stopx = anint( (maxlong-emiss_west) / (emissivity_res) ) + 1
682 starty = anint( (emiss_north-maxlat ) / (emissivity_res) ) + 1
683 stopy = anint( (emiss_north-minlat ) / (emissivity_res) ) + 1
687 if (startx == 0) startx = 1
688 if (stopx == num_emiss_cols+1 ) stopx = num_emiss_cols
689 if (starty == 0) starty = 1
690 if (stopy == num_emiss_rows+1 ) stopy = num_emiss_rows
693 numberofxpoints = stopx - startx + 1
694 numberofypoints = stopy - starty + 1
697 if ( (startx < 1) .or. (stopx > num_emiss_cols) .or. &
698 (starty < 1) .or. (stopy > num_emiss_rows) .or. &
699 (startx > stopx) .or. (starty > stopy) )
then
701 if (stopx > nummapcols) stopx = nummapcols
702 if (stopy > nummaprows) stopy = nummaprows
703 if (startx > stopx) startx = stopx-1
704 if (starty > stopy) starty = stopy-1
705 if (startx < 1) startx = 1
706 if (starty < 1) starty = 1
724 hdfedge(1) = numberofxpoints
725 hdfedge(2) = numberofypoints
728 if(
allocated( emissivity_map ) )
then
729 deallocate( emissivity_map )
731 allocate( emissivity_map(startx:stopx, starty:stopy, 2) )
732 allocate( emissivity_map_int(startx:stopx, starty:stopy ) )
734 status = nf_open(
trim(emissivity_name), nf_nowrite, ecomapfid )
735 call cld_fchk( status, __file__, __line__ )
739 if (i==1) sdsname =
"emiss7"
740 if (i==2) sdsname =
"emiss14"
742 status = nf_inq_varid( ecomapfid,
trim(sdsname), ecomapsdsid )
743 call cld_fchk( status, __file__, __line__ )
745 hdfstatus = nf_get_vara_int2( ecomapfid, ecomapsdsid, hdfstart, &
746 hdfedge, emissivity_map_int )
747 call cld_fchk( status, __file__, __line__ )
749 emissivity_map(:,:,i) = emissivity_map_int * scalefactor
753 status = nf_close( ecomapfid )
754 call cld_fchk( status, __file__, __line__ )
756 deallocate(emissivity_map_int)
764 allocate( snowicetype(1:numberofcols, 1:numberofrows ) )
767 if (errorlevel == fail)
then
770 status,
'getAlbedoEco')
784 do i = 1, numberofcols
785 do j = 1, numberofrows
789 if ( (lat(i,j) >= -90.0000) .and. &
790 (lat(i,j) <= 90.0000) .and. &
791 (long(i,j) >= -180.000) .and. &
792 (long(i,j) <= 180.000) )
then
795 emiss_x = anint( (long(i,j)-emiss_west) / (emissivity_res) ) + 1
796 emiss_y = anint( (emiss_north-lat(i,j)) / (emissivity_res) ) + 1
798 if (emiss_x == 0) emiss_x = 1
799 if (emiss_x == num_emiss_cols+1 ) emiss_x = num_emiss_cols
800 if (emiss_y == 0) emiss_y = 1
801 if (emiss_y == num_emiss_rows+1 ) emiss_y = num_emiss_rows
804 emissivity(i,j, 1) = emissivity_map(emiss_x, emiss_y, 1)
805 emissivity(i,j, 2) = emissivity_map(emiss_x, emiss_y, 2)
807 if (emissivity(i,j,1) < 0.) emissivity(i,j,1) = emissivity_fill
808 if (emissivity(i,j,2) < 0.) emissivity(i,j,2) = emissivity_fill
818 xindex = anint( (long(i,j)-westernmostlongitude) / (map_resolution) ) + 1
819 yindex = anint( (northernmostlatitude-lat(i,j)) / (map_resolution) ) + 1
823 if (xindex == 0) xindex = 1
824 if (xindex == nummapcols+1 ) xindex = nummapcols
825 if (yindex == 0) yindex = 1
826 if (yindex == nummaprows+1 ) yindex = nummaprows
830 if ( (xindex < 1) .or. (xindex > nummapcols) &
831 .or. (yindex < 1) .or. (yindex > nummaprows) )
then
834 'Problem detected, bad array indexes (main loop) ',status,
'getAlbedoEco')
843 if (lat(i,j) >= 40.0 .or. lat(i,j) <= -40.0)
then
844 if (ecosystemmap(xindex,yindex) == 0)
then
848 if ( (icec(i,j) > 0.5 .and. icec(i,j) <= 1.0) &
849 .or. (snowicetype(i,j) == 101) &
850 .or. (snowicetype(i,j) == 200) )
then
853 snowicetype(i,j) = 95
856 if ( (snowicetype(i,j) >= 1 .and. snowicetype(i,j) <= 100) &
857 .or. (snowicetype(i,j) == 200) )
then
859 snowicetype(i,j) = 103
864 if (ecosystemmap(xindex,yindex) == 0)
then
865 if ( snowicetype(i,j) >= 30 .and. snowicetype(i,j) <= 100)
then
866 snowicetype(i,j) = snowicetype(i,j)
871 if ( icec(i,j) > 0. .and. icec(i,j) <= 1.0 ) &
872 snowicetype(i,j) = nint(icec(i,j)*100)
874 if ( icec(i,j) > 0.5 .and. icec(i,j) <= 1.0 ) &
875 snowicetype(i,j) = nint(icec(i,j)*100)
882 ecosystem(i,j) = ecosystemmap(xindex,yindex)
889 if ( (snowicetype(i,j) >= 1) &
890 .and. (snowicetype(i,j) <= 100) &
891 .and. (ecosystem(i,j) == 0) )
then
900 if (lat(i,j) >= 0.0)
then
902 SELECT CASE (julianday)
903 CASE ( (nhmeltbeg-transitiondays):nhmeltbeg-1)
907 slope(:) = (processmeltseaicealbedos(:) - &
908 processdryseaicealbedos(:)) /
real(transitiondays)
909 intercept(:) = processdryseaicealbedos(:) - slope(:) &
910 *
real(nhmeltbeg-transitiondays)
911 transitionalbedo(:) = slope(:) *
real(julianday) + intercept(:)
912 albedo_real4(:) = (transitionalbedo(:) * &
913 real(snowicetype(i,j))/100.000) &
914 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
915 CASE ( nhmeltbeg:nhmeltend )
917 albedo_real4(:) = (processmeltseaicealbedos(:) * &
918 real(snowicetype(i,j))/100.000) &
919 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
920 CASE ( nhmeltend+1:(nhmeltend+transitiondays) )
924 slope(:) = (processdryseaicealbedos(:)- &
925 processmeltseaicealbedos(:)) /
real(transitiondays)
926 intercept(:) = processmeltseaicealbedos(:) - slope(:) &
928 transitionalbedo(:) = slope(:) *
real(julianday) + intercept(:)
929 albedo_real4(:) = (transitionalbedo(:) * &
930 real(snowicetype(i,j))/100.000) &
931 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
934 albedo_real4(:) = (processdryseaicealbedos(:) * &
935 real(snowicetype(i,j))/100.000) &
936 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
943 SELECT CASE (julianday)
944 CASE ( (shmeltbeg-transitiondays):shmeltbeg-1)
948 slope(:) = (processmeltseaicealbedos(:)- &
949 processdryseaicealbedos(:)) &
950 /
real(transitiondays)
951 intercept(:) = processdryseaicealbedos(:) - slope(:) &
952 *
real(shmeltbeg-transitiondays)
953 transitionalbedo(:) = slope(:) *
real(julianday) + intercept(:)
954 albedo_real4(:) = (transitionalbedo(:) * &
955 real(snowicetype(i,j))/100.000) &
956 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
958 CASE ( shmeltbeg:366 )
960 albedo_real4(:) = (processmeltseaicealbedos(:) * &
961 real(snowicetype(i,j))/100.000) &
962 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
965 albedo_real4(:) = (processmeltseaicealbedos(:) * &
966 real(snowicetype(i,j))/100.000) &
967 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
968 CASE (shmeltend+1:(shmeltend+transitiondays) )
972 slope(:) = (processdryseaicealbedos(:)- &
973 processmeltseaicealbedos(:)) /
real(transitiondays)
974 intercept(:) = processmeltseaicealbedos(:) - slope(:) * &
977 transitionalbedo(:) = slope(:) *
real(julianday) + intercept(:)
978 albedo_real4(:) = (transitionalbedo(:) * &
979 real(snowicetype(i,j))/100.000) &
980 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
984 albedo_real4(:) = (processdryseaicealbedos(:) * &
985 real(snowicetype(i,j))/100.000) &
986 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
991 albedo(i,j,:) = nint(albedo_real4(:)*1000.)
993 else if ( ecosystem(i,j) == 15 .or. snowicetype(i,j) == 101 )
then
996 if ((ecosystem(i,j) == 15) .and. &
1002 albedo(i,j,:) = nint( (1.0 - emissivity(i,j,1))*1000.)
1010 albedo(i,j,:) = nint(processsnowalbstats(:, ecosystem(i,j), 1)*1000.)
1012 albedo(i,j,6) = nint( (1.0 - emissivity(i,j,1))*1000.)
1016 else if ( snowicetype(i,j) == 103 )
then
1019 albedo(i,j,:) = nint( processsnowalbstats(:, ecosystem(i,j), 1) * 1000.)
1022 albedo(i,j,6) = nint( (1.0 - emissivity(i,j,1))*1000.)
1029 else if (snowicetype(i,j) >= 30 .and. snowicetype(i,j) <= 100 .and. &
1030 ecosystem(i,j) /= 0)
then
1032 (1.-snowicetype(i,j)*0.01) + &
1033 snowicetype(i,j)*0.01* &
1034 processsnowalbstats(:, ecosystem(i,j), 1)) * 1000.)
1036 albedo(i,j,6) = nint( (1.0 - emissivity(i,j,1))*1000.)
1043 else if ( snowicetype(i,j) == 104 )
then
1046 albedo(i,j,:) = nint(processsnowalbstats(:, ecosystem(i,j), 2) * 1000.)
1048 albedo(i,j,6) = nint((1.0 - emissivity(i,j,1))*1000.)
1054 else if (ecosystem(i,j) == 0)
then
1056 albedo(i,j,:) = nint(wateralbedo*1000.)
1069 albedo(i,j,6) = nint((1.0 - emissivity(i,j,1))*1000.)
1077 albedo(i,j,:) = -999
1078 emissivity(i,j,:) = -999.
1090 deallocate( snowicetype )
1093 if (status > 0 )
then
1096 status,
'getAlbedoEco')