Changeset 2766 for LMDZ5/trunk/libf/dynphy_lonlat/phylmd
- Timestamp:
- Jan 19, 2017, 4:56:16 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ5/trunk/libf/dynphy_lonlat/phylmd/limit_netcdf.F90
r2665 r2766 17 17 !------------------------------------------------------------------------------- 18 18 19 USE ioipsl, ONLY: flininfo, flinopen, flinget, flinclo, & 20 ioconf_calendar, ioget_calendar, lock_calendar, ioget_mon_len, ioget_year_len 19 USE ioipsl, ONLY: flininfo, flinopen, flinget, flinclo 21 20 USE assert_eq_m, ONLY: assert_eq 21 USE cal_tools_m, ONLY: year_len, mid_month 22 22 USE conf_dat_m, ONLY: conf_dat2d, conf_dat3d 23 23 USE dimphy, ONLY: klon, zmasq 24 USE geometry_mod, ONLY: longitude_deg, latitude_deg24 USE geometry_mod, ONLY: longitude_deg, latitude_deg 25 25 USE phys_state_var_mod, ONLY: pctsrf 26 USE control_mod, ONLY: anneeref26 USE control_mod, ONLY: anneeref 27 27 USE init_ssrf_m, ONLY: start_init_subsurf 28 28 … … 123 123 124 124 !--- Beware: anneeref (from gcm.def) is used to determine output time sampling 125 ndays= ioget_year_len(anneeref)125 ndays=year_len(anneeref) 126 126 127 127 !--- RUGOSITY TREATMENT -------------------------------------------------------- … … 375 375 !--- Read unit for sea-ice variable only 376 376 IF (mode=='SIC') THEN 377 IF(NF90_GET_ATT(ncid, varid, 'units', unit_sic)/=NF90_NOERR) THEN 377 ierr=NF90_GET_ATT(ncid, varid, 'units', unit_sic); CALL strclean(unit_sic) 378 IF(ierr/=NF90_NOERR) THEN 378 379 CALL msg(5,'No unit in sea-ice file. Take percentage as default value') 379 380 unit_sic='X' 381 ELSE IF(ANY(["% ","1.0","1 "]==unit_sic)) THEN 382 CALL msg(5,'Sea-ice cover has unit='//TRIM(unit_sic)) 380 383 ELSE 381 CALL msg(5,'Sea-ice cover has unit='//TRIM(unit_sic)) 384 CALL abort_physic('SIC','Unrecognized unit for sea-ice file: '& 385 //TRIM(unit_sic),1) 382 386 END IF 383 387 END IF … … 418 422 !--- Rebuilding input time vector (field from input file might be unreliable) 419 423 IF(lmdep==12) THEN 420 timeyear=mid_month(anneeref, cal_in , ndays_in)424 timeyear=mid_month(anneeref, cal_in) 421 425 CALL msg(0,'Monthly input file(s) for '//TRIM(title)//'.') 422 426 ELSE IF(lmdep==ndays_in) THEN … … 426 430 WRITE(mess,'(a,i3,a,i3,a)')'Mismatching input file: found',lmdep, & 427 431 ' records, 12/',ndays_in,' (monthly/daily needed).' 428 CALL abort_physic('mid_month s',TRIM(mess),1)432 CALL abort_physic('mid_month',TRIM(mess),1) 429 433 END IF 430 434 … … 433 437 IF(extrp) ALLOCATE(work(imdep, jmdep)) 434 438 CALL msg(5,'') 435 CALL msg(5,' LECTURE ET INTERPOLATION HORIZ. DE ', lmdep, ' CHAMPS.')439 CALL msg(5,'READ AND INTERPOLATE HORIZONTALLY ', lmdep, ' FIELDS.') 436 440 CALL ncerr(NF90_INQ_VARID(ncid, varname, varid), fnam) 437 441 DO l=1, lmdep 438 442 CALL ncerr(NF90_GET_VAR(ncid,varid,champ,[1,1,l],[imdep,jmdep,1]),fnam) 443 !--- Check whether values are acceptable for SIC, depending on unit. 444 IF(mode=='SIC') THEN 445 IF(TRIM(unit_sic)=="1".OR.TRIM(unit_sic)=="1.0") THEN 446 IF(ANY(champ>1.0+EPSFRA)) & 447 CALL abort_physic('SIC','Found sea-ice fractions greater than 1.') 448 ELSE IF(TRIM(unit_sic)=="X".OR.TRIM(unit_sic)=="%") THEN 449 IF(ANY(champ>100.0+EPSFRA)) & 450 CALL abort_physic('SIC','Found sea-ice percentages greater than 100.') 451 END IF 452 END IF 439 453 CALL conf_dat2d(title, dlon_ini, dlat_ini, dlon, dlat, champ, .TRUE.) 440 454 IF(extrp) CALL extrapol(champ,imdep,jmdep,999999.,.TRUE.,.TRUE.,2,work) 441 455 IF(l==1) THEN 442 456 CALL msg(5,"----------------------------------------------------------") 443 CALL msg(5,"$$$ Interpolation barycentrique pour "//TRIM(title)//" $$$")457 CALL msg(5,"$$$ Barycentrique interpolation for "//TRIM(title)//" $$$") 444 458 CALL msg(5,"----------------------------------------------------------") 445 459 END IF … … 504 518 IF(ndays/=ndays_in) THEN 505 519 WRITE(lunout, *) 506 WRITE(lunout,*)'DIFFERENT ES LONGEURS D ANNEES:'507 WRITE(lunout,*)' Dans le fichier d entree: ',ndays_in508 WRITE(lunout,*)' Dans le fichier de sortie: ',ndays520 WRITE(lunout,*)'DIFFERENT YEAR LENGTHS:' 521 WRITE(lunout,*)' In the input file: ',ndays_in 522 WRITE(lunout,*)' In the output file: ',ndays 509 523 END IF 510 524 IF(lmdep==ndays_in) THEN 511 525 WRITE(lunout, *) 512 WRITE(lunout, *)' PAS D INTERPOLATION TEMPORELLE.'513 WRITE(lunout, *)' Fichier journalier en entree.'526 WRITE(lunout, *)'NO TIME INTERPOLATION.' 527 WRITE(lunout, *)' Daily input file.' 514 528 ELSE 515 WRITE(lunout, *)' INTERPOLATION TEMPORELLE.'516 WRITE(lunout, *)' Vecteur temps en entree: ', timeyear517 WRITE(lunout, *)' Vecteur temps en sortie de 0 a', ndays-1529 WRITE(lunout, *)'TIME INTERPOLATION.' 530 WRITE(lunout, *)' Input time vector: ', timeyear 531 WRITE(lunout, *)' Output time vector from 0 to ', ndays-1 518 532 END IF 519 533 END IF … … 542 556 DO j=1, jjp1 543 557 CALL minmax(iip1, champan(1, j, 10), chmin, chmax) 544 IF (prt_level>5) WRITE(lunout, *)' ',TRIM(title),' a u temps10 ', chmin, chmax, j558 IF (prt_level>5) WRITE(lunout, *)' ',TRIM(title),' at time 10 ', chmin, chmax, j 545 559 END DO 546 560 547 561 !--- SPECIAL FILTER FOR SST: SST>271.38 -------------------------------------- 548 562 IF(mode=='SST') THEN 549 CALL msg( 5,'Filtrage de laSST: SST >= 271.38')563 CALL msg(0,'Filtering SST: SST >= 271.38') 550 564 WHERE(champan<271.38) champan=271.38 551 565 END IF … … 553 567 !--- SPECIAL FILTER FOR SIC: 0.0<SIC<1.0 ------------------------------------- 554 568 IF(mode=='SIC') THEN 555 CALL msg(5,'Filtrage de la SIC: 0.0 < Sea-ice < 1.0') 556 557 IF (unit_sic=='1') THEN 569 CALL msg(0,'Filtering SIC: 0.0 < Sea-ice < 1.0') 570 IF(TRIM(unit_sic)=="1".OR.TRIM(unit_sic)=="1.0") THEN 558 571 ! Nothing to be done for sea-ice field is already in fraction of 1 559 572 ! This is the case for sea-ice in file cpl_atm_sic.nc 560 CALL msg( 5,'Sea-ice field already in fraction of 1')573 CALL msg(0,'Sea-ice field already in fraction of 1') 561 574 ELSE 562 575 ! Convert sea ice from percentage to fraction of 1 563 CALL msg( 5,'Transformt sea-ice field from percentage to fraction of 1.')576 CALL msg(0,'Sea-ice field converted from percentage to fraction of 1.') 564 577 champan(:, :, :)=champan(:, :, :)/100. 565 578 END IF 566 567 579 champan(iip1, :, :)=champan(1, :, :) 568 580 WHERE(champan>1.0) champan=1.0 … … 647 659 !------------------------------------------------------------------------------- 648 660 ! 649 FUNCTION year_len(y,cal_in)650 !651 !-------------------------------------------------------------------------------652 IMPLICIT NONE653 !-------------------------------------------------------------------------------654 ! Arguments:655 INTEGER :: year_len656 INTEGER, INTENT(IN) :: y657 CHARACTER(LEN=*), INTENT(IN) :: cal_in658 !-------------------------------------------------------------------------------659 ! Local variables:660 CHARACTER(LEN=20) :: cal_out ! calendar (for outputs)661 !-------------------------------------------------------------------------------662 !--- Getting the input calendar to reset at the end of the function663 CALL ioget_calendar(cal_out)664 665 !--- Unlocking calendar and setting it to wanted one666 CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_in))667 668 !--- Getting the number of days in this year669 year_len=ioget_year_len(y)670 671 !--- Back to original calendar672 CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_out))673 674 END FUNCTION year_len675 !676 !-------------------------------------------------------------------------------677 678 679 !-------------------------------------------------------------------------------680 !681 FUNCTION mid_month(y,cal_in,ndays_out)682 !683 !-------------------------------------------------------------------------------684 IMPLICIT NONE685 !-------------------------------------------------------------------------------686 ! Arguments:687 INTEGER, INTENT(IN) :: y ! year688 CHARACTER(LEN=*), INTENT(IN) :: cal_in ! calendar689 INTEGER, INTENT(IN) :: ndays_out ! days number690 REAL, DIMENSION(14) :: mid_month ! mid-bins times691 !-------------------------------------------------------------------------------692 ! Local variables:693 CHARACTER(LEN=99) :: mess ! error message694 CHARACTER(LEN=20) :: cal_out ! output calendar695 INTEGER, DIMENSION(14) :: tlen ! months lengths (days)696 INTEGER :: m ! months counter697 INTEGER :: nd ! number of days698 !-------------------------------------------------------------------------------699 !--- Save the input calendar to reset it at the end of the function700 CALL ioget_calendar(cal_out)701 702 !--- Unlock calendar and set it to "cal_in"703 CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_in))704 705 !--- Get the length of each month706 tlen(1 )=ioget_mon_len(y-1,12)707 DO m=1,12; tlen(m+1)=ioget_mon_len(y,m); END DO708 tlen(14)=ioget_mon_len(y+1, 1)709 710 !--- Mid-bins times711 mid_month(1)=-0.5*REAL(tlen(1))712 DO m=2,14; mid_month(m)=mid_month(m-1)+0.5*REAL(tlen(m-1)+tlen(m)); END DO713 714 !--- Back to original calendar715 CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_out))716 717 END FUNCTION mid_month718 !719 !-------------------------------------------------------------------------------720 721 722 723 !-------------------------------------------------------------------------------724 !725 661 SUBROUTINE msg(lev,str1,i,str2) 726 662 !
Note: See TracChangeset
for help on using the changeset viewer.