Changeset 8377 for branches/ORCHIDEE_2_2/ORCHIDEE/src_oasisdriver
- Timestamp:
- 2024-01-14T15:15:57+01:00 (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ORCHIDEE_2_2/ORCHIDEE/src_oasisdriver/orchideeoasis.f90
r7265 r8377 22 22 !! 23 23 !! SVN : 24 !! $HeadURL: $25 !! $Date: $26 !! $Revision: $24 !! $HeadURL: svn://forge.ipsl.jussieu.fr/orchidee/trunk/ORCHIDEE/src_oasisdriver/orchideeoasis.f90 $ 25 !! $Date: 2023-08-17 23:22:02 +0200 (Thu, 17 Aug 2023) $ 26 !! $Revision: 8140 $ 27 27 !! \n 28 28 !_ ================================================================================================================================ … … 35 35 USE netcdf 36 36 ! 37 USE xios 37 38 ! 38 39 USE ioipsl_para … … 40 41 ! 41 42 USE grid 43 USE time 42 44 USE timer 43 45 USE constantes 46 USE constantes_soil 44 47 USE globgrd 45 48 USE orchoasis_tools … … 48 51 USE control 49 52 USE ioipslctrl 53 USE xios_orchidee 50 54 ! 51 55 USE mod_oasis … … 65 69 REAL(r_std), ALLOCATABLE, DIMENSION(:,:,:,:) :: corners_glo 66 70 REAL(r_std), ALLOCATABLE, DIMENSION(:,:,:) :: corners_lon, corners_lat 71 REAL(r_std), ALLOCATABLE, DIMENSION(:,:,:) :: corners_lon_tmp, corners_lat_tmp 67 72 INTEGER(i_std) :: nbindex_g, kjpindex 68 73 INTEGER(i_std), ALLOCATABLE, DIMENSION(:) :: kindex, kindex_g … … 78 83 !- 79 84 INTEGER(i_std) :: i, j, ik, nbdt, first_point 85 INTEGER :: ierr 80 86 INTEGER(i_std) :: itau, itau_offset, itau_sechiba 81 REAL(r_std) :: date0, date0_shifted, dt, julian , julian087 REAL(r_std) :: date0, date0_shifted, dt, julian 82 88 INTEGER(i_std) :: rest_id, rest_id_stom 83 89 INTEGER(i_std) :: hist_id, hist2_id, hist_id_stom, hist_id_stom_IPCC 84 90 REAL(r_std), ALLOCATABLE, DIMENSION(:,:) :: lalo_loc 85 INTEGER(i_std) :: iim, jjm 91 INTEGER(i_std) :: iim, jjm, in, jk 86 92 REAL(r_std), ALLOCATABLE, DIMENSION(:,:) :: lon, lat 87 93 !- … … 110 116 !- output fields 111 117 !- 112 REAL(r_std), ALLOCATABLE, DIMENSION (:) :: z0 !! Surface roughness 118 REAL(r_std), ALLOCATABLE, DIMENSION (:) :: z0m !! Surface momentum roughness 119 REAL(r_std), ALLOCATABLE, DIMENSION (:) :: z0h !! Surface scalar transport roughness 113 120 REAL(r_std), ALLOCATABLE, DIMENSION (:) :: coastalflow !! Diffuse flow of water into the ocean (m^3/dt) 114 121 REAL(r_std), ALLOCATABLE, DIMENSION (:) :: riverflow !! Largest rivers flowing into the ocean (m^3/dt) … … 128 135 REAL(r_std), ALLOCATABLE, DIMENSION (:,:) :: lai !! Leaf area index (m^2 m^{-2} 129 136 REAL(r_std), ALLOCATABLE, DIMENSION (:,:) :: height !! Vegetation Height (m) 137 REAL(r_std), ALLOCATABLE, DIMENSION (:) :: run_off_lic !! Calving, melting and liquid precipitation, needed when coupled to atmosphere 138 REAL(r_std), ALLOCATABLE, DIMENSION (:) :: run_off_lic_frac !! Cell fraction corresponding to run_off_lic 139 130 140 !- 131 141 !- Declarations for OASIS … … 178 188 ! Set parallel processing in ORCHIDEE 179 189 ! 180 CALL Init_orchidee_para(LOCAL_OASIS_COMM )190 CALL Init_orchidee_para(LOCAL_OASIS_COMM, .TRUE.) 181 191 !==================================================================================== 182 192 ! … … 275 285 !- 276 286 CALL orchoasis_time(date0, dt, nbdt) 287 CALL time_initialize(0, date0, dt, "END") 277 288 !- 278 289 !- lalo needs to be created before going into the parallel region … … 355 366 ! 356 367 ALLOCATE(lon(iim,jjm), lat(iim,jjm)) 368 ALLOCATE(corners_lon(nbseg,iim,jj_para_nb(mpi_rank)), corners_lat(nbseg,iim,jj_para_nb(mpi_rank))) 357 369 ALLOCATE(kindex(kjpindex)) 358 370 ! 359 371 lon=lon_glo(:,jj_para_begin(mpi_rank):jj_para_end(mpi_rank)) 360 372 lat=lat_glo(:,jj_para_begin(mpi_rank):jj_para_end(mpi_rank)) 373 DO in=1,nbseg 374 DO j=1,jj_para_nb(mpi_rank) 375 jk=jj_para_begin(mpi_rank)+(j-1) 376 DO i=1,iim 377 ! Copy the corners/bounds of the meshes which are local to this processor. 378 ! Serves for OASIS and XIOS. 379 corners_lon(in,i,j)=corners_glo(i,jk,in,1) 380 corners_lat(in,i,j)=corners_glo(i,jk,in,2) 381 ENDDO 382 ENDDO 383 ENDDO 361 384 ! 362 385 ! … … 407 430 ALLOCATE(carbwh(kjpindex), carbha(kjpindex)) 408 431 ALLOCATE(tsol_rad(kjpindex), temp_sol_new(kjpindex), qsurf(kjpindex)) 409 ALLOCATE(albedo(kjpindex,2), emis(kjpindex), z0 (kjpindex))432 ALLOCATE(albedo(kjpindex,2), emis(kjpindex), z0m(kjpindex), z0h(kjpindex)) 410 433 ALLOCATE(veget(kjpindex,nvm)) 411 434 ALLOCATE(lai(kjpindex,nvm)) 412 435 ALLOCATE(height(kjpindex,nvm)) 436 ALLOCATE(run_off_lic(kjpindex)) 437 ALLOCATE(run_off_lic_frac(kjpindex)) 438 413 439 ! 414 440 WRITE(numout,*) "Rank", mpi_rank, "Domain size per proc !:", iim_glo, jjm_glo, kjpindex, SIZE(kindex) 415 441 WRITE(numout,*) "Rank", mpi_rank, "In parallel region land index starts at : ", kindex(1) 416 !417 CALL orchoasis_time(date0, dt, nbdt)418 !419 CALL control_initialize420 dt_sechiba = dt421 !422 itau = 0423 !424 CALL ioipslctrl_restini(itau, date0, dt, rest_id, rest_id_stom, itau_offset, date0_shifted)425 !426 ! Get the date of the first time step427 !428 julian = date0 + 0.5*(dt/one_day)429 CALL ju2ymds (julian, year, month, day, sec)430 !431 in_julian = itau2date(itau, date0, dt)432 CALL ymds2ju (year,1,1,zero, julian0)433 julian_diff = in_julian-julian0434 435 CALL xios_orchidee_init( MPI_COMM_ORCH, &436 date0, year, month, day, julian_diff, &437 lon, lat )438 !439 itau_sechiba = itau + itau_offset440 !441 WRITE(numout,*) "orchoasis_history :", iim, jjm, SHAPE(lon)442 !- Initialize IOIPSL sechiba output files443 CALL ioipslctrl_history(iim, jjm, lon, lat, kindex, kjpindex, itau_sechiba, &444 date0, dt, hist_id, hist2_id, hist_id_stom, hist_id_stom_IPCC)445 WRITE(numout,*) "HISTORY : Define for ", itau, date0, dt446 442 ! 447 443 !- … … 462 458 CALL oasis_write_grid(oasis_gridname, iim_glo, jjm_glo, lon_glo, lat_glo) 463 459 ! 464 ALLOCATE(corners_lon (iim_glo, jjm_glo, nbseg), corners_lat(iim_glo, jjm_glo, nbseg))465 corners_lon (:,:,:) = corners_glo(:,:,:,1)466 corners_lat (:,:,:) = corners_glo(:,:,:,2)467 CALL oasis_write_corner(oasis_gridname, iim_glo, jjm_glo, nbseg, corners_lon , corners_lat)460 ALLOCATE(corners_lon_tmp(iim_glo, jjm_glo, nbseg), corners_lat_tmp(iim_glo, jjm_glo, nbseg)) 461 corners_lon_tmp(:,:,:) = corners_glo(:,:,:,1) 462 corners_lat_tmp(:,:,:) = corners_glo(:,:,:,2) 463 CALL oasis_write_corner(oasis_gridname, iim_glo, jjm_glo, nbseg, corners_lon_tmp, corners_lat_tmp) 468 464 ! 469 465 ALLOCATE(maskinv_glo(iim_glo, jjm_glo)) … … 490 486 CALL oasis_write_grid(oasis_gridname, iim_glo, jjm_glo, lon_glo, lat_glo) 491 487 ! 492 CALL oasis_write_corner(oasis_gridname, iim_glo, jjm_glo, nbseg, corners_lon , corners_lat)488 CALL oasis_write_corner(oasis_gridname, iim_glo, jjm_glo, nbseg, corners_lon_tmp, corners_lat_tmp) 493 489 ! 494 490 CALL oasis_write_mask(oasis_gridname, iim_glo, jjm_glo, maskinv_glo) … … 498 494 CALL oasis_terminate_grids_writing() 499 495 ENDIF 500 DEALLOCATE(corners_lon , corners_lat)496 DEALLOCATE(corners_lon_tmp, corners_lat_tmp) 501 497 ! 502 498 ENDIF … … 512 508 CALL orchoasis_defvar(mpi_rank, kjpindex) 513 509 ! 510 !--------------------------------------------------------------------------------------- 511 !- 512 !- Initialize the restart process and XIOS. 513 !- 514 !--------------------------------------------------------------------------------------- 515 CALL control_initialize 516 dt_sechiba = dt 517 ! 518 itau = 0 519 ! 520 CALL ioipslctrl_restini(itau, date0, dt, rest_id, rest_id_stom, itau_offset, date0_shifted) 521 ! 522 ! Get the date of the first time step 523 ! 524 ! To ensure that itau starts with 0 at date0 for the restart, we have to set an off-set to achieve this. 525 ! itau_offset will get used to prduce itau_sechiba. 526 ! 527 itau_offset=-itau_offset-1 528 ! 529 ! Get the date of the first time step 530 ! 531 WRITE(numout,*) "itau_offset : itau_offset : ", itau_offset 532 WRITE(numout,*) "itau_offset : date0 ymd : ", year_end, month_end, day_end, sec_end 533 WRITE(numout,*) "itau_offset : date0, sec, dt : ", sec_end, dt 534 535 CALL xios_orchidee_init( MPI_COMM_ORCH, & 536 date0, year_end, month_end, day_end, julian_diff, & 537 lon, lat, corners_lon, corners_lat ) 538 ! 539 CALL sechiba_xios_initialize 540 ! 541 CALL xios_orchidee_close_definition 542 WRITE(numout,*) 'After xios_orchidee_close_definition' 543 ! 544 itau_sechiba = itau + itau_offset 545 ! 546 WRITE(numout,*) "orchoasis_history :", iim, jjm, SHAPE(lon) 547 !- Initialize IOIPSL sechiba output files 548 CALL ioipslctrl_history(iim, jjm, lon, lat, kindex, kjpindex, itau_sechiba, & 549 date0, dt, hist_id, hist2_id, hist_id_stom, hist_id_stom_IPCC) 550 WRITE(numout,*) "HISTORY : Define for ", itau, date0, dt 551 ! 514 552 !- 515 553 !--------------------------------------------------------------------------------------- … … 519 557 !--------------------------------------------------------------------------------------- 520 558 !- 559 !- Some default values so that the operations before the ORCHIDEE initialisation do not fail. 560 !- 561 z0m(:) = 0.1 562 albedo(:,:) = 0.13 563 !- 521 564 itau = 0 522 julian = date0 + (itau+0.5)*(dt/one_day)523 CALL ju2ymds (julian, year, month, day, sec)524 565 !- 525 566 !--------------------------------------------------------------------------------------- … … 532 573 DO itau=1,nbdt 533 574 ! 534 julian = date0 + (itau-0.5)*(dt/one_day) 535 ! Needed for STOMATE but should be taken from the arguments of SECHIBA 536 in_julian = itau2date(itau, date0, dt) 537 ! 538 CALL ju2ymds (julian, year, month, day, sec) 539 CALL ymds2ju (year,1,1,zero, julian0) 540 julian_diff = in_julian-julian0 575 CALL time_nextstep( itau ) 576 julian = (julian_start + julian_end) /2.0 !julian_end 541 577 ! 542 578 ! … … 581 617 peqAcoef(:) = zero 582 618 ! 583 CALL orchoasis_printpoint(julian, testpt(1), testpt(2), kjpindex, lalo_loc, z0 , &619 CALL orchoasis_printpoint(julian, testpt(1), testpt(2), kjpindex, lalo_loc, z0m, & 584 620 & "Z0 before compute", ktest) 585 621 ! 586 ! Interpolate the wind (which is at hight zlev_uv) to the same height587 ! as the temperature and humidity (at zlev_tq).588 !589 u_tq(:) = u(:)*LOG(zlev_tq(:)/z0(:))/LOG(zlev_uv(:)/z0(:))590 v_tq(:) = v(:)*LOG(zlev_tq(:)/z0(:))/LOG(zlev_uv(:)/z0(:))591 622 ! 592 623 CALL orchoasis_printpoint(julian, testpt(1), testpt(2), kjpindex, lalo_loc, u_tq, "USED East-ward wind") … … 613 644 CALL xios_orchidee_update_calendar(itau_sechiba) 614 645 ! 646 ! Use the obtained albedo to diagnose the Downward Solar and the wind at the right level 647 ! 648 swdown(:) = swnet(:)/(1.-(albedo(:,1)+albedo(:,2))/2.) 649 u_tq(:) = u(:)*LOG(zlev_tq(:)/z0m(:))/LOG(zlev_uv(:)/z0m(:)) 650 v_tq(:) = v(:)*LOG(zlev_tq(:)/z0m(:))/LOG(zlev_uv(:)/z0m(:)) 651 ! 615 652 IF ( itau == 1 ) THEN 616 653 ! … … 623 660 ! 624 661 CALL sechiba_initialize( & 625 itau_sechiba, iim*jjm, kjpindex, kindex, &662 itau_sechiba, iim*jjm, kjpindex, kindex, & 626 663 lalo_loc, contfrac, neighbours, resolution, zlev_tq, & 627 u_tq, v_tq, qair, temp_air, &628 petAcoef, peqAcoef, petBcoef, peqBcoef, &629 precip_rain, precip_snow, lwdown, swnet, swdown, &664 u_tq, v_tq, qair, temp_air, & 665 petAcoef, peqAcoef, petBcoef, peqBcoef, & 666 precip_rain, precip_snow, lwdown, swnet, swdown, & 630 667 pb, rest_id, hist_id, hist2_id, & 631 668 rest_id_stom, hist_id_stom, hist_id_stom_IPCC, & 632 coastalflow, riverflow, tsol_rad, vevapp, qsurf, &633 z0 , albedo, fluxsens, fluxlat, emis,&669 coastalflow, riverflow, tsol_rad, vevapp, qsurf, & 670 z0m, z0h, albedo, fluxsens, fluxlat, emis, & 634 671 temp_sol_new, cdrag) 635 672 CALL orchoasis_printpoint(julian, testpt(1), testpt(2), kjpindex, lalo_loc, temp_sol_new, "Init temp_sol_new") 636 !637 ! Use the obtained albedo to diagnose the Downward Solar638 !639 swdown(:) = swnet(:)/(1.-(albedo(:,1)+albedo(:,2))/2.)640 673 ! 641 674 lrestart_read = .FALSE. … … 674 707 & netco2, carblu, carbwh, carbha, & 675 708 ! Surface temperatures and surface properties 676 & tsol_rad, temp_sol_new, qsurf, albedo, emis, z0 , &709 & tsol_rad, temp_sol_new, qsurf, albedo, emis, z0m, z0h, & 677 710 ! Vegeation, lai and vegetation height 678 711 & veget, lai, height, & 679 712 ! File ids 680 713 & rest_id, hist_id, hist2_id, rest_id_stom, hist_id_stom, hist_id_stom_IPCC) 681 !682 ! Use the obtained albedo to diagnose the Downward Solar683 !684 swdown(:) = swnet(:)/(1.-(albedo(:,1)+albedo(:,2))/2.)714 !!$ ! 715 !!$ ! Use the obtained albedo to diagnose the Downward Solar 716 !!$ ! 717 !!$ swdown(:) = swnet(:)/(1.-(albedo(:,1)+albedo(:,2))/2.) 685 718 ! 686 719 CALL orchoasis_printpoint(julian, testpt(1), testpt(2), kjpindex, lalo_loc, temp_sol_new, "Produced temp_sol_new") … … 701 734 CALL orchoasis_putvar(itau, dt, kjpindex, kindex - (ii_begin - 1),& 702 735 & vevapp, fluxsens, fluxlat, coastalflow, riverflow, & 703 & netco2, carblu, tsol_rad, temp_sol_new, qsurf, albedo, emis, z0 )736 & netco2, carblu, tsol_rad, temp_sol_new, qsurf, albedo, emis, z0m, z0h) 704 737 ! 705 738 IF ( timemeasure ) THEN … … 723 756 ! 724 757 CALL xios_orchidee_send_field("LandPoints" ,(/ ( REAL(ik), ik=1,kjpindex ) /)) 725 CALL xios_orchidee_send_field("Areas", area) 726 CALL xios_orchidee_send_field("Contfrac",contfrac) 727 CALL xios_orchidee_send_field("evap",vevapp*one_day/dt_sechiba) 728 CALL xios_orchidee_send_field("evap_alma",vevapp/dt_sechiba) 729 CALL xios_orchidee_send_field("coastalflow",coastalflow/dt_sechiba) 730 CALL xios_orchidee_send_field("riverflow",riverflow/dt_sechiba) 731 CALL xios_orchidee_send_field("temp_sol_C",temp_sol_new-ZeroCelsius) 732 CALL xios_orchidee_send_field("temp_sol_K",temp_sol_new) 733 CALL xios_orchidee_send_field("fluxsens",fluxsens) 734 CALL xios_orchidee_send_field("fluxlat",fluxlat) 735 CALL xios_orchidee_send_field("tair",temp_air) 758 CALL xios_orchidee_send_field("areas", area) 759 CALL xios_orchidee_send_field("contfrac",contfrac) 760 CALL xios_orchidee_send_field("temp_air",temp_air) 736 761 CALL xios_orchidee_send_field("qair",qair) 737 762 CALL xios_orchidee_send_field("swnet",swnet) 738 763 CALL xios_orchidee_send_field("swdown",swdown) 739 764 ! zpb in hPa, output in Pa 740 CALL xios_orchidee_send_field(" Psurf",pb*100.)765 CALL xios_orchidee_send_field("pb",pb) 741 766 ! 742 767 IF ( .NOT. almaoutput ) THEN … … 829 854 ! 830 855 CALL histclo 856 ! 831 857 IF(is_root_prc) THEN 832 858 CALL restclo … … 840 866 !- 841 867 CALL orchideeoasis_clear() 842 !843 WRITE(numout,*) "MPI finalized"844 868 !- 845 869 IF ( timemeasure ) THEN … … 855 879 CALL stop_timer(timer_mpi) 856 880 ENDIF 881 ! 882 ! Finalize MPI and XIOS 883 !! CALL Finalize_mpi 884 CALL xios_context_finalize() 885 CALL xios_finalize() 857 886 !- 858 887 CALL oasis_terminate(ierror) 888 !! CALL MPI_FINALIZE(ierr) 859 889 ! 860 890 WRITE(numout,*) "OASIS terminated" … … 875 905 876 906 !- Deallocate all variables existing on all procs (list still incomplete) 877 907 878 908 IF ( ALLOCATED(lon_glo) ) DEALLOCATE(lon_glo) 879 909 IF ( ALLOCATED(lat_glo) ) DEALLOCATE(lat_glo) … … 925 955 IF ( ALLOCATED(albedo) ) DEALLOCATE(albedo) 926 956 IF ( ALLOCATED(emis) ) DEALLOCATE(emis) 927 IF ( ALLOCATED(z0) ) DEALLOCATE(z0) 957 958 !!$ IF ( ALLOCATED(z0m) ) DEALLOCATE(z0m) 959 !!$ IF ( ALLOCATED(z0h) ) DEALLOCATE(z0h) 928 960 929 961 CALL sechiba_clear()
Note: See TracChangeset
for help on using the changeset viewer.