Changeset 429 for branches/GRISLIv3


Ignore:
Timestamp:
04/25/23 18:08:16 (15 months ago)
Author:
dumas
Message:

Use only in module spinup_vitbil

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GRISLIv3/SOURCES/spinup_mod.f90

    r206 r429  
    1919module spinup_vitbil 
    2020 
    21   use module3D_phy 
    22   use param_phy_mod 
    23   use deformation_mod_2lois 
    24   use interface_input 
    25   use io_netcdf_grisli 
    26    
     21  use geography, only: nx,ny,nz 
     22 
    2723  implicit none 
    2824 
     
    3632  real, dimension(nx,ny) :: init_coefmy      !< rescalling coefficient before limitation 
    3733 
    38 ! compatibilites avec remplimat 
     34  ! compatibilites avec remplimat 
    3935  logical :: corr_def = .False.               !< for deformation correction (compatibility) 
    4036 
    4137  real, dimension(nx,ny) :: Vsl_x             !< 
    4238  real, dimension(nx,ny) :: Vsl_y             !< 
    43    
     39 
    4440  integer :: type_vitbil ! defini le type de fichier a lire : lect_vitbil ou lect_vitbil_Lebrocq 
    4541 
     
    5147  !< 
    5248  subroutine init_spinup 
    53   namelist/spinup/ispinup,type_vitbil 
     49 
     50    use module3D_phy, only: ispinup,num_param,num_rep_42 
     51    use runparam, only : itracebug 
     52     
     53    namelist/spinup/ispinup,type_vitbil 
    5454 
    5555    ! put here which type of spinup 
     
    6363    ! ispinup = 3                          ! fait le calcul des temperatures  
    6464    !                                      ! avec les vitesses de bilan 
    65    
    66  
    67  
    68  
    69 ! lecture des parametres 
    70  
    71 rewind(num_param)        ! pour revenir au debut du fichier param_list.dat 
    72 read(num_param,spinup) 
    73  
    74 write(num_rep_42,*)'!___________________________________________________________' 
    75 write(num_rep_42,*)'!        spinup          module spinup_vitbil               ' 
    76 write(num_rep_42,spinup)                   ! pour ecrire les parametres lus 
    77 write(num_rep_42,*) 
    78 write(num_rep_42,*) 
    79 write(num_rep_42,*)'! ispinup = 0     run standard voir no_spinup' 
    80 write(num_rep_42,*)'! ispinup = 1     equilibre temperature avec vitesses grisli voir no_spinup' 
    81 write(num_rep_42,*) 
    82 write(num_rep_42,*)'! ispinup >1      use spinup_vitbil' 
    83 write(num_rep_42,*)'! ispinup = 2     conservation de la masse avec vitesses bilan ' 
    84 write(num_rep_42,*)'! ispinup = 3     equilibre temperature avec vitesses bilan' 
    85 write(num_rep_42,*)'! type_vitbil type de lecture des vitesses de bilan 1: lect_vitbil, 2 : lect_vitbil_Lebrocq' 
    86 write(num_rep_42,*) 
    87  
    88   
    89 if (ispinup.eq.0) then 
    90    write(6,*)' ispinup = 0 et ispinup = 1 doivent etre appeles par no_spinup ' 
    91    write(6,*) 'et il faut rajouter un dragging' 
    92    stop 
    93 endif 
    94  
    95 if (ispinup.eq.3) then 
    96   select case (type_vitbil) 
    97   case (1) 
    98 !cdc Methode Cat lecture fichier selon x et y sur grille stag 
    99     call lect_vitbil 
    100   case(2) 
    101 !cdc Methode Tof lecture fichier Lebrocq vitesse et direction 
    102     call lect_vitbil_Lebrocq 
    103   case default 
    104     print*,'type_vitbil valeur invalide dans spinup_vitbil' 
    105     stop 
    106   end select 
    107 endif 
     65 
     66 
     67 
     68 
     69    ! lecture des parametres 
     70 
     71    rewind(num_param)        ! pour revenir au debut du fichier param_list.dat 
     72    read(num_param,spinup) 
     73 
     74    write(num_rep_42,*)'!___________________________________________________________' 
     75    write(num_rep_42,*)'!        spinup          module spinup_vitbil               ' 
     76    write(num_rep_42,spinup)                   ! pour ecrire les parametres lus 
     77    write(num_rep_42,*) 
     78    write(num_rep_42,*) 
     79    write(num_rep_42,*)'! ispinup = 0     run standard voir no_spinup' 
     80    write(num_rep_42,*)'! ispinup = 1     equilibre temperature avec vitesses grisli voir no_spinup' 
     81    write(num_rep_42,*) 
     82    write(num_rep_42,*)'! ispinup >1      use spinup_vitbil' 
     83    write(num_rep_42,*)'! ispinup = 2     conservation de la masse avec vitesses bilan ' 
     84    write(num_rep_42,*)'! ispinup = 3     equilibre temperature avec vitesses bilan' 
     85    write(num_rep_42,*)'! type_vitbil type de lecture des vitesses de bilan 1: lect_vitbil, 2 : lect_vitbil_Lebrocq' 
     86    write(num_rep_42,*) 
     87 
     88 
     89    if (ispinup.eq.0) then 
     90       write(6,*)' ispinup = 0 et ispinup = 1 doivent etre appeles par no_spinup ' 
     91       write(6,*) 'et il faut rajouter un dragging' 
     92       stop 
     93    endif 
     94 
     95    if (ispinup.eq.3) then 
     96       select case (type_vitbil) 
     97       case (1) 
     98          !cdc Methode Cat lecture fichier selon x et y sur grille stag 
     99          call lect_vitbil 
     100       case(2) 
     101          !cdc Methode Tof lecture fichier Lebrocq vitesse et direction 
     102          call lect_vitbil_Lebrocq 
     103       case default 
     104          print*,'type_vitbil valeur invalide dans spinup_vitbil' 
     105          stop 
     106       end select 
     107    endif 
    108108 
    109109    if (itracebug.eq.1)  call tracebug(' fin routine init_spinup de spinup_vitbil') 
     
    111111 
    112112  subroutine lect_vitbil 
    113  
     113     
     114    use module3D_phy, only: debug_3D,num_rep_42,num_param 
     115    use io_netcdf_grisli, only: Read_Ncdf_var 
     116    use geography, only: dirnameinp 
     117    use runparam, only : itracebug 
     118     
    114119    character(len=100) :: balance_Ux_file        !  balance velocity file Ux 
    115120    character(len=100) :: balance_Uy_file        !  balance velocity file Uy 
    116           real*8, dimension(:,:),   pointer    :: tab               !< tableau 2d real pointer 
    117            
     121    real*8, dimension(:,:),   pointer    :: tab               !< tableau 2d real pointer 
     122 
    118123    namelist/vitbil_upwind/balance_Ux_file, balance_Uy_file   
    119124 
     
    135140 
    136141    ! read balance velocities on staggered nodes 
    137      
     142 
    138143    balance_Ux_file = trim(dirnameinp)//trim(balance_Ux_file) 
    139144    balance_Uy_file = trim(dirnameinp)//trim(balance_Uy_file) 
    140      
     145 
    141146    call Read_Ncdf_var('Vcol_x',balance_Ux_file,tab) 
    142147    Vcol_x(:,:)=tab(:,:) 
     
    144149    Vcol_y(:,:)=tab(:,:) 
    145150 
    146 !    call lect_input(2,'Vcol',1,Vcol_x,balance_vel_file,trim(dirnameinp)//trim(runname)//'.nc')  !read Vcol_x 
    147 !    call lect_input(2,'Vcol',2,Vcol_y,balance_vel_file,trim(dirnameinp)//trim(runname)//'.nc')  !read Vcol_y 
     151    !    call lect_input(2,'Vcol',1,Vcol_x,balance_vel_file,trim(dirnameinp)//trim(runname)//'.nc')  !read Vcol_x 
     152    !    call lect_input(2,'Vcol',2,Vcol_y,balance_vel_file,trim(dirnameinp)//trim(runname)//'.nc')  !read Vcol_y 
    148153    !call lect_datfile(nx,ny,Vcol_x,1,balance_vel_file)   ! read Vcol_x    
    149154    !call lect_datfile(nx,ny,Vcol_y,2,balance_vel_file)   ! read Vcol_y  
     
    153158 
    154159  end subroutine lect_vitbil 
    155    
     160 
    156161  subroutine lect_vitbil_Lebrocq 
    157162 
    158  
     163    use module3D_phy, only: num_rep_42,mstream_mx,itracebug,num_param,pi 
     164    use io_netcdf_grisli, only: Read_Ncdf_var 
     165    use geography, only: dirnameinp 
     166    use runparam, only : itracebug 
     167     
    159168    character(len=100) :: vit_balance_file        !  balance velocity file 
    160169    character(len=100) :: flowdir_balance_file    !  balance flow direction file 
     
    164173    real, dimension(nx,ny) :: Vx_Lebrocq, Vy_Lebrocq ! vitesses selon x et y 
    165174    integer, dimension(nx,ny) :: v_good  !points avec vitesse Lebrocq OK 
    166      
     175    integer :: i,j 
     176 
    167177    namelist/vitbil_Lebrocq/vit_balance_file, flowdir_balance_file   
    168178 
     
    184194 
    185195    ! read balance velocities on staggered nodes 
    186      
     196 
    187197    vit_balance_file = trim(dirnameinp)//trim(vit_balance_file) 
    188198    flowdir_balance_file = trim(dirnameinp)//trim(flowdir_balance_file) 
    189      
     199 
    190200    call Read_Ncdf_var('z',vit_balance_file,tab) 
    191201    V_Lebrocq(:,:)=tab(:,:) 
     
    194204 
    195205    where (V_Lebrocq(:,:).ge.0.) 
    196       v_good(:,:)=1 
     206       v_good(:,:)=1 
    197207    elsewhere 
    198       v_good(:,:)=0 
     208       v_good(:,:)=0 
    199209    endwhere 
    200      
     210 
    201211    do j=2,ny-1 
    202       do i=2,nx-1 
    203         if (V_Lebrocq(i,j).lt.0.) then 
    204            
    205           V_Lebrocq(i,j)= (V_Lebrocq(i-1,j)*v_good(i-1,j) + V_Lebrocq(i+1,j)*v_good(i+1,j) + & 
    206                          V_Lebrocq(i,j-1)*v_good(i,j-1) + V_Lebrocq(i,j+1)*v_good(i,j+1)) / & 
    207                          (v_good(i-1,j)+v_good(i+1,j)+v_good(i,j-1)+v_good(i,j-1)) 
    208         endif 
    209       enddo 
     212       do i=2,nx-1 
     213          if (V_Lebrocq(i,j).lt.0.) then 
     214 
     215             V_Lebrocq(i,j)= (V_Lebrocq(i-1,j)*v_good(i-1,j) + V_Lebrocq(i+1,j)*v_good(i+1,j) + & 
     216                  V_Lebrocq(i,j-1)*v_good(i,j-1) + V_Lebrocq(i,j+1)*v_good(i,j+1)) / & 
     217                  (v_good(i-1,j)+v_good(i+1,j)+v_good(i,j-1)+v_good(i,j-1)) 
     218          endif 
     219       enddo 
    210220    enddo 
    211221 
    212222 
    213223    where (V_Lebrocq(:,:).ge.100.) 
    214       V_Lebrocq(:,:)=100. 
     224       V_Lebrocq(:,:)=100. 
    215225    endwhere 
    216226 
    217                 ! calcul des vitesses selon x et selon y : 
    218                 where (V_Lebrocq(:,:).ge.0.) 
    219                         Vx_Lebrocq(:,:) = V_Lebrocq(:,:)*sin(flowdir_Lebrocq(:,:)) 
    220                         Vy_Lebrocq(:,:) = V_Lebrocq(:,:)*cos(flowdir_Lebrocq(:,:)) 
    221                 elsewhere 
    222                         Vx_Lebrocq(:,:) = 0. 
    223                         Vy_Lebrocq(:,:) = 0. 
    224                 endwhere 
    225  
    226                  
    227                 ! calcul des vitesses sur les points staggered 
    228                  
    229                 do j=2,ny 
    230                         do i=2,nx 
    231                                 Vcol_x(i,j) = (Vx_Lebrocq(i-1,j) + Vx_Lebrocq(i,j))/2. 
    232                                 Vcol_y(i,j) = (Vy_Lebrocq(i,j-1) + Vy_Lebrocq(i,j))/2. 
    233                         enddo 
    234                 enddo 
    235  
    236   end subroutine lect_vitbil_Lebrocq  
     227    ! calcul des vitesses selon x et selon y : 
     228    where (V_Lebrocq(:,:).ge.0.) 
     229       Vx_Lebrocq(:,:) = V_Lebrocq(:,:)*sin(flowdir_Lebrocq(:,:)) 
     230       Vy_Lebrocq(:,:) = V_Lebrocq(:,:)*cos(flowdir_Lebrocq(:,:)) 
     231    elsewhere 
     232       Vx_Lebrocq(:,:) = 0. 
     233       Vy_Lebrocq(:,:) = 0. 
     234    endwhere 
     235 
     236 
     237    ! calcul des vitesses sur les points staggered 
     238 
     239    do j=2,ny 
     240       do i=2,nx 
     241          Vcol_x(i,j) = (Vx_Lebrocq(i-1,j) + Vx_Lebrocq(i,j))/2. 
     242          Vcol_y(i,j) = (Vy_Lebrocq(i,j-1) + Vy_Lebrocq(i,j))/2. 
     243       enddo 
     244    enddo 
     245 
     246  end subroutine lect_vitbil_Lebrocq 
    237247  !____________________________________________________________________________________ 
    238248 
     
    242252  subroutine init_dragging      ! Cette routine fait l'initialisation du dragging. 
    243253 
     254    use module3D_phy, only: mstream_mx,mstream_my,drag_mx,drag_my,gzmx,gzmy,flgzmx,flgzmy,flotmx,flotmy 
     255     
    244256    implicit none 
    245257 
     
    265277 
    266278  subroutine force_balance_vel 
    267  
     279     
     280    use module3D_phy, only: uxbar, uybar,debug_3D 
     281    use runparam, only : itracebug 
    268282    if (itracebug.eq.1)  call tracebug(' Subroutine force_balance_vel') 
    269283 
     
    281295  !< 
    282296  subroutine calc_coef_vitbil 
    283  
     297     
     298    use module3D_phy, only: ddbx,ddby,gzmx,gzmy,flgzmx,flgzmy,fleuvemx,fleuvemy,flot,flotmx,flotmy,& 
     299         coefmxbmelt,coefmybmelt,sdx,sdy,uxbar,uybar,uxdef,uydef,ubx,uby,debug_3D,iglen 
     300    use deformation_mod_2lois, only: n1poly,n2poly,sa_mx,sa_my,s2a_mx,s2a_my 
     301    use runparam, only : itracebug 
     302     
     303    integer :: i,j,k 
     304     
    284305    ddbx(:,:)=0. 
    285306    ddby(:,:)=0. 
     
    290311    fleuvemx(:,:)=.false. 
    291312    fleuvemy(:,:)=.false. 
    292      
     313 
    293314    do j=2,ny 
    294       do i=2,nx 
     315       do i=2,nx 
    295316          if (flot(i,j).and.(flot(i-1,j))) then 
    296             flotmx(i,j)=.true. 
    297             flgzmx(i,j)=.true. 
    298             gzmx(i,j)=.false. 
     317             flotmx(i,j)=.true. 
     318             flgzmx(i,j)=.true. 
     319             gzmx(i,j)=.false. 
    299320          end if 
    300321          if (flot(i,j).and.(flot(i,j-1))) then 
    301             flotmy(i,j)=.true. 
    302             flgzmy(i,j)=.true. 
    303             gzmy(i,j)=.false. 
     322             flotmy(i,j)=.true. 
     323             flgzmy(i,j)=.true. 
     324             gzmy(i,j)=.false. 
    304325          end if 
    305       end do 
    306     end do    
    307      
     326       end do 
     327    end do 
     328 
    308329    where (coefmxbmelt(:,:).le.0.) 
    309       gzmx(:,:)=.false. 
     330       gzmx(:,:)=.false. 
    310331    endwhere 
    311332    where (coefmybmelt(:,:).le.0.) 
    312       gzmy(:,:)=.false. 
     333       gzmy(:,:)=.false. 
    313334    endwhere 
    314335    flgzmx(:,:) = flgzmx(:,:) .or. gzmx(:,:) 
     
    316337    fleuvemx(:,:)=gzmx(:,:) 
    317338    fleuvemy(:,:)=gzmy(:,:) 
    318      
     339 
    319340    if (itracebug.eq.1)  call tracebug(' Subroutine  calc_coef_vitbil') 
    320341    call slope_surf 
     
    341362             coef_defmx(i,j) = 1. 
    342363             Uxbar(i,j)      = Vcol_x(i,j) 
    343 ! dmr below is a cast from a real*4 to logical*4 
    344 ! dmr cannot be implicit in gfortran 
    345 ! dmr              flgzmx(i,j)     = Vcol_x(i,j) 
     364             ! dmr below is a cast from a real*4 to logical*4 
     365             ! dmr cannot be implicit in gfortran 
     366             ! dmr              flgzmx(i,j)     = Vcol_x(i,j) 
    346367             flgzmx(i,j)     = (nint(Vcol_x(i,j)).ne.0) 
    347368             uxdef(i,j)      = 0. 
     
    365386                   coef_defmx(i,j)=Vcol_x(i,j)/Ux_deformation(i,j) 
    366387                   ddbx(i,j) = 0 
    367                     Ubx(i,j)  = 0. 
     388                   Ubx(i,j)  = 0. 
    368389                else 
    369390                   coef_defmx(i,j)=1.                                  ! no rescaling of deformation 
     
    385406             coef_defmy(i,j) = 1. 
    386407             Uybar(i,j)      = Vcol_y(i,j) 
    387 ! dmr below is a cast from a real*4 to logical*4 
    388 ! dmr cannot be implicit in gfortran 
    389 ! dmr             flgzmy(i,j)     = Vcol_y(i,j) 
     408             ! dmr below is a cast from a real*4 to logical*4 
     409             ! dmr cannot be implicit in gfortran 
     410             ! dmr             flgzmy(i,j)     = Vcol_y(i,j) 
    390411             flgzmy(i,j)     = (nint(Vcol_y(i,j)).ne.0) 
    391412 
     
    393414             Uby(i,j)        = Vcol_y(i,j) 
    394415 
    395  if ((itracebug.eq.1).and.(i.eq.313).and.(j.eq.143))  call tracebug(' test0') 
     416             if ((itracebug.eq.1).and.(i.eq.313).and.(j.eq.143))  call tracebug(' test0') 
    396417          else 
    397418             coldy:      if ((coefmybmelt(i,j).le.0.).and.(.not.gzmy(i,j))) then   !base froide  
     
    402423                if (abs(Uy_deformation(i,j)).gt.0.01) then             ! calcule par calc_ubar_def 
    403424                   coef_defmy(i,j)=Vcol_y(i,j)/Uy_deformation(i,j) 
    404  if ((itracebug.eq.1).and.(i.eq.313).and.(j.eq.143))  call tracebug(' test1') 
     425                   if ((itracebug.eq.1).and.(i.eq.313).and.(j.eq.143))  call tracebug(' test1') 
    405426                else 
    406  if ((itracebug.eq.1).and.(i.eq.313).and.(j.eq.143))  call tracebug(' test2') 
     427                   if ((itracebug.eq.1).and.(i.eq.313).and.(j.eq.143))  call tracebug(' test2') 
    407428                   coef_defmy(i,j)=1. 
    408429                end if 
     
    412433                   ddby(i,j) = 0. 
    413434                   Uby(i,j)  = 0. 
    414  if ((itracebug.eq.1).and.(i.eq.313).and.(j.eq.143))  call tracebug(' test3') 
     435                   if ((itracebug.eq.1).and.(i.eq.313).and.(j.eq.143))  call tracebug(' test3') 
    415436                else 
    416437                   coef_defmy(i,j)=1.                                  ! pas de rescaling de la deformation 
    417438                   ddby(i,j)=-(Vcol_y(i,j)-Uy_deformation(i,j))/sdy(i,j)        ! pb si directions opposees 
    418439                   Uby(i,j) =  Vcol_y(i,j)-Uy_deformation(i,j) 
    419 if ((itracebug.eq.1).and.(i.eq.313).and.(j.eq.144))  call tracebug(' test4') 
     440                   if ((itracebug.eq.1).and.(i.eq.313).and.(j.eq.144))  call tracebug(' test4') 
    420441 
    421442                end if 
     
    426447       end do 
    427448    end do 
    428  if (itracebug.eq.1)  call tracebug(' apres test floty') 
     449    if (itracebug.eq.1)  call tracebug(' apres test floty') 
    429450 
    430451    ! remarque coef peut être <1  a cause de la pente locale, mais il joue toujours son role  
     
    453474 
    454475  subroutine limit_coef_vitbil 
    455  
     476     
     477    use module3D_phy, only: sdx,sdy,flotmx,flotmy,coefmxbmelt,coefmybmelt,gzmx,gzmy,ddbx,ddby,debug_3D,& 
     478         iglen 
     479    use deformation_mod_2lois, only: n1poly,n2poly,sa_mx,sa_my,s2a_mx,s2a_my 
     480    use runparam, only : itracebug 
     481     
     482    integer :: i,j,k 
     483     
    456484    call slope_surf 
    457485 
     
    583611  subroutine calc_ubar_def   ! calculate velocity due to deformation before calibration 
    584612 
     613    use module3D_phy, only: iglen,flotmx,flotmy,hmx,hmy,sdx,sdy,slope2mx,slope2my 
     614    use deformation_mod_2lois, only: n1poly,n2poly,glen,s2a_mx,s2a_my,ddx,ddy 
     615    use geography, only: dx,dy 
     616    use param_phy_mod, only: rog 
     617    use runparam, only: itracebug 
     618     
    585619    implicit none              ! extrait de diffusiv pour calculer la partie deformation 
    586620 
     
    588622    real :: inv_4dx ! inverse de dx pour eviter les divisions =1/(4*dx) 
    589623    real :: inv_4dy ! inverse de dy pour eviter les divisions =1/(4*dy) 
     624    integer :: i,j 
    590625 
    591626    inv_4dx=1./(4*dx) 
     
    646681 
    647682  subroutine ajust_ghf 
    648  
     683     
     684    use module3D_phy, only: debug_3D,flot,ibase,ghf,ghf0,secyear 
     685     
    649686    implicit none 
     687     
    650688    real,dimension(nx,ny) :: coefdef_maj     !< coefficient deformation 
    651689    real :: increment_ghf 
    652690    real :: ghf_min 
     691    integer :: i,j 
     692     
    653693    increment_ghf=0.00001                    !< exprime en  W/m2    
    654694    ghf_min=0.025                                            
Note: See TracChangeset for help on using the changeset viewer.