Changeset 2289 for trunk/LMDZ.MARS/util
- Timestamp:
- Apr 16, 2020, 7:11:13 PM (5 years ago)
- Location:
- trunk/LMDZ.MARS/util
- Files:
-
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/util/solzenangle.F90
r2288 r2289 1 program terminator1 program solzenangle 2 2 3 3 ! ---------------------------------------------------------------------------- 4 4 ! Program to redistribute and interpolate the variables at the local time 5 ! corresponding to one terminator (morning or evening) everywhere 5 ! corresponding to one solar zenith angle (morning or evening) everywhere 6 ! It can especially be used for the terminator (sza=90deg) 6 7 ! input : diagfi.nc / concat.nc / stats.nc kind of files 7 8 ! authors: A.Bierjon,F.Forget,2020 … … 33 34 ! altpositive(): [netcdf] altitude "positive" attribute 34 35 35 character (len= 8) :: sunterm36 ! sunterm(): type of terminator ("sunrise" for the morning, "sunset" for the evening)36 character (len=7) :: planetside 37 ! planetside(): planet side of the solar zenith angle ("morning" or "evening") 37 38 38 39 integer :: nid,ierr,miss,validr … … 103 104 real, dimension(:), allocatable :: intsol 104 105 real, dimension(:,:,:), allocatable :: lt_out 106 real :: sza ! solar zenith angle 107 character (len=30) :: szastr ! to store the sza value in a string 105 108 real :: starttimeoffset ! offset (in sols) of sol 0 in input file, wrt Ls=0 106 109 real :: tmpsol ! to temporarily store a sol value … … 113 116 real :: miss_lt 114 117 PARAMETER(miss_lt=1E+20) 115 ! miss_lt: [netcdf] missing value to write for the terminatorLocal Time in the output file118 ! miss_lt: [netcdf] missing value to write for the Local Time in the output file 116 119 real, dimension(2) :: valid_range 117 120 ! valid_range(2): [netcdf] interval in which a value is considered valid … … 122 125 ! 1.1. Get input file name(s) 123 126 !============================================================================== 127 write(*,*) "Welcome in the solar zenith angle interpolator program !" 124 128 write(*,*) 125 129 write(*,*) "which file do you want to use? (diagfi... stats... concat...)" … … 430 434 ! 2.4.1 Select local times to be saved "Time" in output file 431 435 !============================================================================== 432 write(*,*) 'Type of terminator?' 433 read(*,*) sunterm 434 if ((trim(sunterm).ne."sunrise").and.(trim(sunterm).ne."sunset")) then 435 write(*,*) "sunterm = "//sunterm 436 write(*,*) "Error: terminator type must be sunrise or sunset" 436 write(*,*) "Planet side of the Solar Zenith Angle ?" 437 read(*,*) planetside 438 if ((trim(planetside).ne."morning").and.(trim(planetside).ne."evening")) then 439 write(*,*) "planetside = "//planetside 440 write(*,*) "Error: the planet side must be morning or evening" 441 stop 442 endif 443 write(*,*) "Solar Zenith angle to interpolate ?" 444 write(*,*) "(between 0 and 180 deg, 90deg for the terminator at the surface)" 445 read(*,*) sza 446 if ((sza.lt.0).or.(sza.ge.180)) then 447 write(*,*) "ERROR: the solar zenith angle must lie within [0;180[ deg" 437 448 stop 438 449 endif … … 470 481 do ilon=1,lonlen 471 482 ! For the computation of Ls, it's supposed that the morning/evening 472 ! terminator happens atLT=6h/18h at the given longitude, which is483 ! correspond to LT=6h/18h at the given longitude, which is 473 484 ! then reported to a sol value at longitude 0 474 if (trim( sunterm).eq."sunrise") then485 if (trim(planetside).eq."morning") then 475 486 tmpsol = intsol(it) + (6.-lon(ilon)/15.)/24. + starttimeoffset 476 else !if trim( sunterm).eq."sunset"487 else !if trim(planetside).eq."evening" 477 488 tmpsol = intsol(it) + (18.-lon(ilon)/15.)/24. + starttimeoffset 478 489 endif 479 490 call sol2ls(tmpsol,tmpLs) 480 491 do ilat=1,latlen 481 ! Compute the Local Time of the terminatorat a given longitude482 call LT terminator(lat(ilat),tmpLs,sunterm,miss_lt,tmpLT)492 ! Compute the Local Time of the solar zenith angle at a given longitude 493 call LTsolzenangle(lat(ilat),tmpLs,planetside,sza,miss_lt,tmpLT) 483 494 ! Deduce the sol value at this longitude 484 495 if (tmpLT.eq.miss_lt) then 485 ! if there is no terminator, put a missing value in lt_out496 ! if there is no LT corresponding to the sza, put a missing value in lt_out 486 497 lt_out(ilon,ilat,it)=miss_lt 487 498 else … … 517 528 ! 2.4.2. Get output file name 518 529 !============================================================================== 519 if (trim( sunterm).eq."sunrise") then520 filename=file(1:len_trim(file)-3)//"_ TMO.nc"521 else ! if trim( sunterm).eq."sunset"522 filename=file(1:len_trim(file)-3)//"_ TEV.nc"530 if (trim(planetside).eq."morning") then 531 filename=file(1:len_trim(file)-3)//"_MO.nc" 532 else ! if trim(planetside).eq."evening" 533 filename=file(1:len_trim(file)-3)//"_EV.nc" 523 534 endif 524 535 … … 741 752 742 753 !============================================================================== 743 ! 2.5.6 Write the terminatorLocal Time variable in output file744 !============================================================================== 745 write(*,*) "variable LT terminator"754 ! 2.5.6 Write the solar zenith angle Local Time variable in output file 755 !============================================================================== 756 write(*,*) "variable LTsolzenangle" 746 757 ! build dim(),corner() and edges() arrays 747 758 dim(1)=londimout … … 761 772 edges(4)=1 762 773 763 tmpvar="LTterminator" 764 units="hour(LTST)" 765 if (trim(sunterm).eq."sunrise") then 766 title="Morning Terminator Local Time" 767 else !if trim(sunterm).eq."sunset" 768 title="Evening Terminator Local Time" 774 tmpvar="LTsolzenangle" 775 units="hours" 776 write(szastr,*) sza 777 if (trim(planetside).eq."morning") then 778 title="Morning-side LTST at sza="//trim(adjustl(szastr))//"deg" 779 else !if trim(planetside).eq."evening" 780 title="Evening-side LTST at sza="//trim(adjustl(szastr))//"deg" 769 781 endif 770 782 call def_var(nout,tmpvar,title,units,3,dim,varidout,ierr) … … 802 814 write(*,*) "Program completed !" 803 815 804 end program terminator816 end program solzenangle 805 817 806 818 … … 1414 1426 1415 1427 !****************************************************************************** 1416 subroutine LT terminator(lat,ls,sunterm,missval,lt_term)1417 ! compute the terminatorlocaltime by inversing1428 subroutine LTsolzenangle(lat,ls,planetside,sza,missval,lt_sza) 1429 ! compute the localtime by inversing 1418 1430 ! the solar zenith angle equation : 1419 ! mu0=sin(lat)*sin(declin)+1420 ! cos(lat)*cos(declin)*cos(2.*pi*(localtime/24.-.5))1421 ! for mu0=cos(sza)=0 (since sza=90deg at the terminator) 1431 ! cos(sza)=sin(lat)*sin(declin) 1432 ! +cos(lat)*cos(declin)*cos(2.*pi*(localtime/24.-.5)) 1433 1422 1434 1423 1435 implicit none … … 1425 1437 real,intent(in) :: lat ! latitude (deg) 1426 1438 real,intent(in) :: ls ! solar longitude (deg) 1427 character (len=8), intent(in) :: sunterm ! terminator type : "sunrise" for morning,"sunset" for evening 1428 real,intent(in) :: missval ! missing value for when there is no terminator (polar day/night) 1429 real,intent(out) :: lt_term ! local true solar time (hours) of the terminator 1439 character (len=7), intent(in) :: planetside ! planet side : "morning" or "evening" 1440 real,intent(in) :: sza ! solar zenith angle (deg) (within [0;180[) 1441 real,intent(in) :: missval ! missing value for when there is no associated LT (polar day/night) 1442 real,intent(out) :: lt_sza ! local true solar time (hours) corresponding to the sza 1430 1443 1431 1444 ! local variables: 1432 1445 double precision :: declin ! declination of the Sun (rad) 1446 double precision :: tmpcos ! to temporarily store a cosine value 1433 1447 double precision,parameter :: obliquity=25.1919d0 1434 1448 double precision,parameter :: pi=3.14159265358979d0 … … 1439 1453 declin=ASIN(sin(ls*degtorad)*sin(obliquity*degtorad)) 1440 1454 1455 ! Small checks 1456 if ((cos(lat*degtorad).eq.0).or.(cos(declin).eq.0)) then 1457 write(*,*) "ERROR in LTsolzenangle : lat and declin can't have their cosine equal to zero" 1458 stop 1459 endif 1460 1441 1461 ! Compute Local Time 1442 if (((-tan(lat*degtorad)*tan(declin)).gt.1.).or.(((-tan(lat*degtorad)*tan(declin)).lt.(-1.)))) then 1462 tmpcos = cos(sza*degtorad)/(cos(lat*degtorad)*cos(declin)) - tan(lat*degtorad)*tan(declin) 1463 1464 if ((tmpcos.gt.1.).or.(tmpcos.lt.(-1.))) then 1443 1465 ! Detect Polar Day and Polar Night (values out of the arccos definition domain) 1444 lt_ term= missval1466 lt_sza = missval 1445 1467 1446 1468 else 1447 1469 1448 if (trim( sunterm).eq."sunrise") then1449 ! Local Time of the Morning Terminator1450 lt_ term = 24*(0.5 - ACOS(-tan(lat*degtorad)*tan(declin))/(2.*pi))1451 else ! if trim( sunterm).eq."sunset"1452 ! Local Time of the Evening Terminator1453 lt_ term = 24*(0.5 + ACOS(-tan(lat*degtorad)*tan(declin))/(2.*pi))1470 if (trim(planetside).eq."morning") then 1471 ! Local Time of the Morning-side Solar Zenith Angle 1472 lt_sza = 24*(0.5 - ACOS(tmpcos)/(2.*pi)) 1473 else ! if trim(planetside).eq."evening" 1474 ! Local Time of the Evening-side Solar Zenith Angle 1475 lt_sza = 24*(0.5 + ACOS(tmpcos)/(2.*pi)) 1454 1476 endif 1455 1477 1456 1478 endif 1457 1479 1458 end subroutine LT terminator1480 end subroutine LTsolzenangle 1459 1481 1460 1482 !****************************************************************************** -
trunk/LMDZ.MARS/util/solzenangle.def
r2288 r2289 4 4 temp 5 5 6 sunrise 6 morning 7 90 7 8 0 8 9 9 10 ----------------------------------------------------------------------- 10 ABOVE is the list of inputs to be fed to " terminator.e" if you don t want11 ABOVE is the list of inputs to be fed to "solzenangle.e" if you don t want 11 12 to reply directly to the program: 12 13 … … 14 15 2) List of X variables to be kept (X lines) or 'all' 15 16 3) blank line at the end 16 4) terminator type (sunrise or sunset) 17 5) starttimeoffset : 17 4) planet side wrt to noon (morning or evening) 18 5) solar zenith angle (within [0;180[ deg) 19 0deg = zenith ; 90deg = terminator at the surface ; >90deg = terminator in altitude 20 6) starttimeoffset : 18 21 - for a diagfi/concat : sol value at the beginning of the run, wrt Ls=0 19 22 - for a stats : sol value at the middle of the run, wrt Ls=0 20 23 21 24 USE : 22 terminator.e < terminator.def25 solzenangle.e < solzenangle.def 23 26 24 27
Note: See TracChangeset
for help on using the changeset viewer.