Ignore:
Timestamp:
Sep 3, 2025, 11:19:36 PM (5 months ago)
Author:
tbertrand
Message:

Pluto PCM:

  • adding option to use N2 ice fractional maps (n2frac) read in the startfi.nc
  • adding option in newstart to correct (tsurf and tsoil) for too warm or too cold N2-free (correct_t_non2) or N2-rich (correct_t_n2) patches

TB

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.PLUTO/libf/dynphy_lonlat/phypluto/newstart.F

    r3878 r3910  
    112112      REAL field_input(ngridmx)
    113113      REAL,ALLOCATABLE :: field_inputs(:,:)
     114      REAL, ALLOCATABLE :: n2fracfi(:)
     115      REAL, ALLOCATABLE :: n2fracdat(:,:)
    114116
    115117      INTEGER i,j,l,isoil,ig,idum,k
     
    155157      real val, val1, val2, val3, val4, dist, ref ! to store temporary variables
    156158      real val5, val6, val7, val8, val9, val10,val11, val12 ! to store temporary variables
     159      real :: val_lat1, val_lat2, val_lon1, val_lon2
     160      real :: phi_min, phi_max, albomin, albomax !temp variables
     161      real :: fact, addch4
    157162      real :: iceith=2000 ! thermal inertia of subterranean ice
    158163      integer :: iref,jref,iref1,jref1,iref2,jref2
     
    233238      allocate(qsurf(ngridmx,nqtot))
    234239      allocate(qsurf_tmp(ngridmx,nqtot))
     240!allocate n2frac
     241      allocate(n2fracfi(ngridmx))
     242      allocate(n2fracdat(iip1, jjp1))
    235243
    236244! get value of nsoilmx and allocate corresponding arrays
     
    671679        write(*,*) 'bladed: add ch4 on bladed terrains'
    672680        write(*,*) 'cpbladed: add extension bladed terrains'
     681        write(*,*) 'modch4_topo: add/remove ch4 (alb+topo)'
    673682        write(*,*) 'slope: add slope over all long. (for triton)'
    674683        write(*,*) 'digsp: specific to dig SP'
    675684        write(*,*) 'bugn2: correct bug of warm n2 due to HighRes'
    676         write(*,*) 'bugn2_new: correct bug of warm n2 due to HighRes'
     685        write(*,*) 'correct_t_non2: correct surf temp of no-n2 patches'
     686        write(*,*) 'correct_t_n2: correct surface temp of warm n2'
    677687        write(*,*) 'bugch4: correct bug of warm ch4 due to HighRes'
    678688        write(*,*) 'flatnosp : topo flat except SP (topo controled)'
     
    689699        write(*,*) 'albedomap: read in an albedomap albedo.nc'
    690700        write(*,*) 'mod_distrib_ice: modify ice distrib. from albedo'
    691 
     701        write(*,*) 'use_n2frac: read a n2frac map'
    692702        write(*,*)
    693703        write(*,*) 'Please note that emis and albedo are set in physiq'
     
    13151325          ENDDO
    13161326
     1327c       modch4_topo : adding/removing ch4 ice with albedo + altitude filter
     1328c       ----------------------------------------------------------
     1329        else if (modif(1:len_trim(modif)) .eq. 'modch4_topo') then
     1330
     1331          write(*,*) 'Adding or removing ch4 (alb+top)'
     1332          write(*,*) 'Choice band : lat1 and lat2 ?'
     1333 1200      read(*,*,iostat=ierr) val_lat1,val_lat2
     1334          if(ierr.ne.0) goto 1200
     1335
     1336          write(*,*) 'Choice band : lon1 and lon2 ?'
     1337 1201      read(*,*,iostat=ierr) val_lon1,val_lon2
     1338          if(ierr.ne.0) goto 1201
     1339
     1340          write(*,*) 'Choice topo window (phi_min phi_max)'
     1341 1202      read(*,*,iostat=ierr) phi_min,phi_max
     1342          if(ierr.ne.0) goto 1202
     1343
     1344          write(*,*) 'Choice albedo window (albomin albomax)'
     1345 1203      read(*,*,iostat=ierr) albomin,albomax
     1346          if(ierr.ne.0) goto 1203
     1347
     1348          write(*,*) 'Choice multiplicative factor for ch4'
     1349 1204      read(*,*,iostat=ierr) fact
     1350          if(ierr.ne.0) goto 1204
     1351
     1352          write(*,*) 'Choice additional ch4'
     1353 1205     read(*,*,iostat=ierr) addch4
     1354          if(ierr.ne.0) goto 1205
     1355
     1356          ! Loop over gridpoints
     1357          DO ig=1,ngridmx
     1358             IF (   (latfi(ig)*180./pi.ge.val_lat1) .and.
     1359     &              (latfi(ig)*180./pi.le.val_lat2) .and.
     1360     &              (lonfi(ig)*180./pi.ge.val_lon1) .and.
     1361     &              (lonfi(ig)*180./pi.le.val_lon2) .and.
     1362     &              (zmea(ig).ge.phi_min)         .and.
     1363     &              (zmea(ig).le.phi_max)         .and.
     1364     &              (albedodat(ig).ge.albomin)      .and.
     1365     &              (albedodat(ig).le.albomax) ) then
     1366
     1367                qsurf(ig,igcm_ch4_ice)=qsurf(ig,igcm_ch4_ice)*fact
     1368                qsurf(ig,igcm_ch4_ice)=qsurf(ig,igcm_ch4_ice)+addch4
     1369
     1370             ENDIF
     1371          ENDDO
     1372
    13171373c       cpbladed : add extension bladed terrains
    13181374c       ----------------------------------------------------------
     
    27562812!        END DO
    27572813
    2758 c       bugn2_new correct bug warm n2 due to change of resolution
     2814c       correct_t_non2 correct tsurf for N2-free surfaces
    27592815c       -----------------------------------------------------
    2760         else if (modif(1:len_trim(modif)) .eq. 'bugn2_new') then
     2816        else if (modif(1:len_trim(modif)) .eq. 'correct_t_non2') then
    27612817               
    27622818          write(*,*) 'Where do you want to apply the change?'
     
    27702826 566      read(*,*,iostat=ierr) val5,val6
    27712827          if(ierr.ne.0) goto 566
     2828          write(*,*) 'Choice of temperature threshold ?'
     2829 567      read(*,*,iostat=ierr) val7
     2830          if(ierr.ne.0) goto 567
    27722831
    27732832          ! let's find where we need to apply the correction
    27742833          ierr=1
    2775           do while (ierr.ne.0)
     2834          do while (ierr.ne.0) ! do a loop until no change is made
    27762835           ierr=0
    27772836           do ig=1,ngridmx
    2778             IF (qsurf(ig,igcm_n2).gt.0.) then
     2837            IF (qsurf(ig,igcm_n2).lt.1.e-6.and.tsurf(ig).le.val7) then
    27792838
    27802839             IF (   (latfi(ig)*180./pi.ge.val)  .and.
     
    27892848                 ignew=0
    27902849                 DO compt=1,4
    2791                     if (qsurf(edge(compt),igcm_n2).le.1.e-6) then
     2850                    if (qsurf(edge(compt),igcm_n2).le.1.e-6.and.
     2851     &                                       tsurf(ig).gt.val7) then
    27922852                       ignew=edge(compt)
    27932853                    endif
     
    27972857                   write(*,*) 'ig=',ig,' replaced with ',ignew
    27982858                   qsurf(ig,igcm_n2)=0.
     2859                   tsurf(ig)=tsurf(ignew)
     2860                   DO l=1,nsoilmx
     2861                       tsoil(ig,l)=tsoil(ignew,l)
     2862                   ENDDO
     2863                 else
     2864                   write(*,*) 'No solution for ig=',ig
     2865                   write(*,*) '  edge=',edge
     2866                 endif
     2867
     2868              ENDIF
     2869             ENDIF
     2870            ENDIF
     2871           end do
     2872          end do
     2873
     2874c       correct_t_n2 : correct tsurf of warm n2 patches
     2875c       -----------------------------------------------------
     2876        else if (modif(1:len_trim(modif)) .eq. 'correct_t_n2') then
     2877               
     2878          write(*,*) 'Where do you want to apply the change?'
     2879          write(*,*) 'Choice band : lat1 and lat2 ?'
     2880 580      read(*,*,iostat=ierr) val,val2
     2881          if(ierr.ne.0) goto 580
     2882          write(*,*) 'Choice band : lon1 and lon2 ?'
     2883 581      read(*,*,iostat=ierr) val3,val4
     2884          if(ierr.ne.0) goto 581
     2885          write(*,*) 'Choice of topography range ?'
     2886 582      read(*,*,iostat=ierr) val5,val6
     2887          if(ierr.ne.0) goto 582
     2888          write(*,*) 'Choice of temperature threshold ?'
     2889 583      read(*,*,iostat=ierr) val7
     2890          if(ierr.ne.0) goto 583
     2891          write(*,*) 'Do you want to remove (0) or keep (1) N2 ice ?'
     2892 584      read(*,*,iostat=ierr) val8
     2893          if(ierr.ne.0) goto 584
     2894
     2895          ! let's find where we need to apply the correction
     2896          ierr=1
     2897          do while (ierr.ne.0)
     2898           ierr=0
     2899           do ig=1,ngridmx
     2900            IF (qsurf(ig,igcm_n2).gt.0..and.tsurf(ig).gt.val7) then
     2901
     2902             IF (   (latfi(ig)*180./pi.ge.val)  .and.
     2903     &              (latfi(ig)*180./pi.le.val2)  .and.
     2904     &              (lonfi(ig)*180./pi.ge.val3)  .and.
     2905     &              (lonfi(ig)*180./pi.le.val4)  ) then
     2906
     2907              IF (   (phisfi(ig).ge.val5)  .and.
     2908     &               (phisfi(ig).le.val6)  ) then
     2909                 ! Get the index of the adjecent points, N,S,E,W
     2910                 call get_next_point(ig,edge)
     2911                 ignew=0
     2912                 DO compt=1,4
     2913                    if (qsurf(edge(compt),igcm_n2).ge.1.e-6) then
     2914                       ignew=edge(compt)
     2915                    endif
     2916                 ENDDO
     2917                 if (ignew.gt.0) then  ! Applying correction
     2918                   ierr=1
     2919                   write(*,*) 'ig=',ig,' replaced with ',ignew
     2920                   if (val8.eq.0) then
     2921                      qsurf(ig,igcm_n2)=0.
     2922                   endif
    27992923                   tsurf(ig)=tsurf(ignew)
    28002924                   DO l=1,nsoilmx
     
    37093833          ENDDO
    37103834
     3835c       read an n2frac map
     3836c       -----------------------------------------------------
     3837        else if (modif(1:len_trim(modif)) .eq. 'use_n2frac') then
     3838
     3839          ! Get field 2D
     3840          fichnom = 'n2frac.nc'
     3841          ierr = NF_OPEN(fichnom, NF_NOWRITE, nid_fi_input)
     3842          IF (ierr .NE. NF_NOERR) THEN
     3843            write(6,*) 'Problem opening n2frac file:', fichnom
     3844            write(6,*) 'ierr = ', ierr
     3845            CALL ABORT
     3846          ENDIF
     3847
     3848          ierr = NF_INQ_VARID(nid_fi_input, "n2frac", nvarid_input)
     3849          IF (ierr .NE. NF_NOERR) THEN
     3850            PRINT*, "Could not find asked variable in n2frac.nc"
     3851            CALL abort
     3852          ENDIF
     3853#ifdef NC_DOUBLE
     3854          ierr = NF_GET_VAR_DOUBLE(nid_fi_input,nvarid_input,
     3855     &                                 field_input)
     3856#else
     3857          ierr = NF_GET_VAR_REAL(nid_fi_input,nvarid_input,field_input)
     3858#endif
     3859          IF (ierr .NE. NF_NOERR) THEN
     3860            PRINT*, "Could not get asked variable in n2frac.nc"
     3861            CALL abort
     3862          ELSE
     3863            PRINT*, "Got variable in n2frac.nc"
     3864          ENDIF
     3865
     3866          ! Transfer the data to the new variables
     3867          DO ig = 1, ngridmx
     3868            n2fracfi(ig) = field_input(ig)
     3869          ENDDO
     3870          print*, "Transferred data to n2fracfi"
     3871          ! Confirmation message
     3872          print*, "n2frac data has been successfully implemented."
     3873
    37113874c       slope : add slope on all longitudes
    37123875c       -----------------------------------------------------
     
    41464309      call physdem1("restartfi.nc",nsoilmx,ngridmx,llm,nqtot,
    41474310     &                dtphys,real(day_ini),
    4148      &                tsurf,tsoil,ithfi,emis,albfi,q2,qsurf)
     4311     &                tsurf,tsoil,ithfi,emis,albfi,q2,qsurf,n2fracfi)
    41494312!     &                cloudfrac,totalfrac,hice,
    41504313!     &                rnat,pctsrf_sic,tslab,tsea_ice,sea_ice)
     
    42044367
    42054368      ! Selection of the adjacent index depending on the grid point
    4206       !! poles (now well implemented yet) 
    4207       IF (ig.eq.1) then 
     4369      !! poles (now well implemented yet)
     4370      IF (ig.eq.1) then
    42084371         edge = (/2, 2+int(iim/4),2+2*int(iim/4),iim+1 /)
    42094372      ELSEIF (ig.eq.ngridmx) then
Note: See TracChangeset for help on using the changeset viewer.