New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 662 – NEMO

Changeset 662


Ignore:
Timestamp:
2007-05-25T17:58:52+02:00 (17 years ago)
Author:
opalod
Message:

RB: update Agrif internal routines with a new update scheme and performance improvment

Location:
trunk/AGRIF/AGRIF_FILES
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/AGRIF/AGRIF_FILES/modarrays.F

    r396 r662  
    332332        Variable%array2 = Value 
    333333      CASE (3) 
    334         Variable%array3 = Value 
     334        Call Agrif_set_tozero3D(Variable%array3) 
     335!        Variable%array3 = Value 
    335336      CASE (4) 
    336337        Variable%array4 = Value 
     
    343344      return 
    344345C 
    345       End Subroutine Agrif_nbdim_Full_VarEQreal        
     346      End Subroutine Agrif_nbdim_Full_VarEQreal    
     347       
     348      Subroutine Agrif_set_tozero3D(tab3D) 
     349      real,dimension(:,:,:),target :: tab3D 
     350       
     351      tab3D = 0. 
     352       
     353      end subroutine agrif_set_tozero3D     
    346354C 
    347355C 
     
    450458     &         Variable2%array1(inf2(1):sup2(1)) 
    451459      CASE (2) 
    452          Variable%array2(inf(1):sup(1), 
    453      &                         inf(2):sup(2)) =  
    454      &         Variable2%array2(inf2(1):sup2(1), 
    455      &                          inf2(2):sup2(2)) 
     460      
     461      Call Agrif_Copy_2d(Variable%array2,Variable2%array2, 
     462     &  lbound(Variable%array2), 
     463     &  lbound(Variable2%array2), 
     464     &  inf,sup,inf2,sup2) 
     465           
    456466      CASE (3) 
    457          Variable%array3(inf(1):sup(1), 
    458      &                         inf(2):sup(2),  
    459      &                         inf(3):sup(3)) =  
    460      &         Variable2%array3(inf2(1):sup2(1), 
    461      &                          inf2(2):sup2(2), 
    462      &                          inf2(3):sup2(3)) 
     467 
     468      Call Agrif_Copy_3d(Variable%array3,Variable2%array3, 
     469     &  lbound(Variable%array3), 
     470     &  lbound(Variable2%array3), 
     471     &  inf,sup,inf2,sup2) 
     472 
    463473      CASE (4) 
    464         Variable%array4(inf(1):sup(1), 
    465      &                         inf(2):sup(2),  
    466      &                         inf(3):sup(3), 
    467      &                         inf(4):sup(4)) =  
    468      &         Variable2%array4(inf2(1):sup2(1), 
    469      &                          inf2(2):sup2(2), 
    470      &                          inf2(3):sup2(3), 
    471      &                          inf2(4):sup2(4)) 
     474       
     475      Call Agrif_Copy_4d(Variable%array4,Variable2%array4, 
     476     &  lbound(Variable%array4), 
     477     &  lbound(Variable2%array4), 
     478     &  inf,sup,inf2,sup2) 
     479      
    472480      CASE (5) 
    473481        Variable%array5(inf(1):sup(1), 
     
    543551C 
    544552C 
    545 C     ************************************************************************** 
    546 CCC   Subroutine Agrif_array2vector 
    547 C     ************************************************************************** 
    548 C 
    549       Subroutine Agrif_array2vector(array,bounds,vector,nbdim) 
    550 C 
    551 CCC   Description: 
    552 CCC   This subroutine is used to record the array into the vector 
    553 C 
    554 C     Declarations: 
    555 C       
    556        
    557 C 
    558 C     Arguments       
    559 C 
    560       TYPE(AGRIF_Variable), Pointer       :: array 
    561       REAL, DIMENSION(:)         :: vector      ! Array used for the time  
    562       INTEGER                    :: nbdim       ! dimension of the table 
    563       INTEGER,DIMENSION(nbdim,2) :: bounds 
    564 C 
    565 C     Local variables        
    566 C 
    567       INTEGER                      :: nind,ir,jr,kr,lr,mr,nr 
    568 C 
    569       SELECT CASE (nbdim) 
    570       CASE (1) 
    571          nind=0 
    572          do ir=bounds(1,1),bounds(1,2) 
    573             nind=nind+1 
    574             array%array1(ir) = vector(nind) 
    575          enddo        
    576 C 
    577       CASE (2) 
    578          nind=0 
    579           do jr=bounds(2,1),bounds(2,2) 
    580            do ir=bounds(1,1),bounds(1,2) 
    581                nind=nind+1 
    582                array%array2(ir,jr) = vector(nind) 
    583            enddo 
    584          enddo         
    585 C 
    586       CASE (3) 
    587          nind=0 
    588         do kr=bounds(3,1),bounds(3,2) 
    589            do jr=bounds(2,1),bounds(2,2) 
    590              do ir=bounds(1,1),bounds(1,2) 
    591                   nind=nind+1 
    592                   array%array3(ir,jr,kr) = vector(nind) 
    593              enddo 
    594            enddo 
    595          enddo       
    596 C 
    597       CASE (4) 
    598          nind=0 
    599         do lr=bounds(4,1),bounds(4,2) 
    600           do kr=bounds(3,1),bounds(3,2) 
    601              do jr=bounds(2,1),bounds(2,2) 
    602                do ir=bounds(1,1),bounds(1,2) 
    603                      nind=nind+1 
    604                      array%array4(ir,jr,kr,lr) = vector(nind) 
    605                enddo 
    606              enddo 
    607            enddo 
    608          enddo           
    609 C 
    610       CASE (5) 
    611          nind=0 
    612          do mr=bounds(5,1),bounds(5,2) 
    613          do lr=bounds(4,1),bounds(4,2) 
    614           do kr=bounds(3,1),bounds(3,2)  
    615               do jr=bounds(2,1),bounds(2,2) 
    616                  do ir=bounds(1,1),bounds(1,2) 
    617                      nind=nind+1 
    618                      array%array5(ir,jr,kr,lr,mr) = vector(nind) 
    619                  enddo 
    620                enddo 
    621              enddo 
    622            enddo 
    623          enddo         
    624 C 
    625       CASE (6) 
    626          nind=0 
    627         do nr=bounds(6,1),bounds(6,2) 
    628           do mr=bounds(5,1),bounds(5,2) 
    629           do lr=bounds(4,1),bounds(4,2) 
    630            do kr=bounds(3,1),bounds(3,2) 
    631              do jr=bounds(2,1),bounds(2,2) 
    632                    do ir=bounds(1,1),bounds(1,2) 
    633                      nind=nind+1 
    634                      array%array6(ir,jr,kr,lr,mr,nr) = vector(nind) 
    635                    enddo 
    636                  enddo 
    637                enddo 
    638              enddo 
    639            enddo 
    640          enddo        
    641         END SELECT 
    642 C 
    643       return 
    644 C 
    645       End Subroutine Agrif_array2vector 
    646 C 
    647 C 
    648 C 
    649 C     ************************************************************************** 
    650 CCC   Subroutine Agrif_vector2array 
    651 C     ************************************************************************** 
    652 C 
    653       Subroutine Agrif_vector2array(vector,array,bounds,nbdim) 
    654 C 
    655 CCC   Description: 
    656 CCC   This subroutine is used to record the array into the vector 
    657 C 
    658 C     Declarations: 
    659 C       
    660        
    661 C 
    662 C     Arguments       
    663 C 
    664       TYPE(AGRIF_Variable), Pointer       :: array 
    665       REAL, DIMENSION(:)         :: vector      ! Array used for the time  
    666       INTEGER                    :: nbdim       ! dimension of the table 
    667       INTEGER,DIMENSION(nbdim,2) :: bounds 
    668 C 
    669 C     Local variables        
    670 C 
    671       INTEGER                      :: nind,ir,jr,kr,lr,mr,nr 
    672 C 
    673       SELECT CASE (nbdim) 
    674       CASE (1) 
    675          nind=0 
    676          do ir=bounds(1,1),bounds(1,2) 
    677             nind=nind+1 
    678             vector(nind) = array%array1(ir) 
    679          enddo        
    680 C 
    681       CASE (2) 
    682          nind=0 
    683         do jr=bounds(2,1),bounds(2,2) 
    684            do ir=bounds(1,1),bounds(1,2) 
    685                nind=nind+1 
    686                vector(nind) = array%array2(ir,jr) 
    687            enddo 
    688          enddo       
    689 C 
    690       CASE (3) 
    691          nind=0 
    692         do kr=bounds(3,1),bounds(3,2) 
    693           do jr=bounds(2,1),bounds(2,2) 
    694              do ir=bounds(1,1),bounds(1,2) 
    695                   nind=nind+1 
    696                   vector(nind) = array%array3(ir,jr,kr) 
    697              enddo 
    698            enddo 
    699          enddo        
    700 C 
    701       CASE (4) 
    702          nind=0 
    703           do lr=bounds(4,1),bounds(4,2) 
    704            do kr=bounds(3,1),bounds(3,2) 
    705              do jr=bounds(2,1),bounds(2,2) 
    706                do ir=bounds(1,1),bounds(1,2) 
    707                      nind=nind+1 
    708                      vector(nind) = array%array4(ir,jr,kr,lr) 
    709                enddo 
    710              enddo 
    711            enddo 
    712          enddo          
    713 C 
    714       CASE (5) 
    715          nind=0 
    716          do mr=bounds(5,1),bounds(5,2) 
    717            do lr=bounds(4,1),bounds(4,2) 
    718             do kr=bounds(3,1),bounds(3,2)  
    719               do jr=bounds(2,1),bounds(2,2) 
    720                  do ir=bounds(1,1),bounds(1,2) 
    721                      nind=nind+1 
    722                      vector(nind) = array%array5(ir,jr,kr,lr,mr) 
    723                  enddo 
    724                enddo 
    725              enddo 
    726            enddo 
    727          enddo    
    728 C 
    729       CASE (6) 
    730          nind=0 
    731         do nr=bounds(6,1),bounds(6,2) 
    732            do mr=bounds(5,1),bounds(5,2) 
    733              do lr=bounds(4,1),bounds(4,2) 
    734                do kr=bounds(3,1),bounds(3,2) 
    735                 do jr=bounds(2,1),bounds(2,2) 
    736                    do ir=bounds(1,1),bounds(1,2) 
    737                      nind=nind+1 
    738                      vector(nind) = array%array6(ir,jr,kr,lr,mr,nr) 
    739                    enddo 
    740                  enddo 
    741                enddo 
    742              enddo 
    743            enddo 
    744          enddo        
    745       END SELECT 
    746 C 
    747       return 
    748 C 
    749       End Subroutine Agrif_vector2array 
    750553 
    751554#ifdef AGRIF_MPI 
     
    13101113#ifdef AGRIF_MPI 
    13111114C 
    1312 C     ************************************************************************** 
    1313 CCC   Subroutine Agrif_GlobtoLocInd 
    1314 C     ************************************************************************** 
    1315 C 
    1316       Subroutine Agrif_GlobtoLocInd(tabarray,lboundl,uboundl,tab1,tab2, 
    1317      &                              nbdim,rank) 
    1318 C 
    1319 CCC   Description: 
    1320 CCC   For a global index located on the current processor, tabarray gives the  
    1321 CCC   corresponding local index    
    1322 C 
    1323 C 
    1324 C     Declarations: 
    1325 C 
    1326  
    1327 C 
    1328 C     Arguments 
    1329       INTEGER :: nbdim 
    1330       INTEGER,DIMENSION(nbdim) :: tab1,tab2 
    1331       INTEGER,DIMENSION(minval(tab1):maxval(tab2),nbdim,2 ) :: tabarray 
    1332       INTEGER,DIMENSION(nbdim) :: lboundl,uboundl 
    1333       INTEGER :: rank 
    1334 C 
    1335 C     Local variables 
    1336       INTEGER :: i,i1,k 
    1337 C 
    1338 C 
    1339       tabarray(:,:,1) = 0 
    1340 C         
    1341       do i = 1,nbdim 
    1342 C        
    1343         Call Agrif_Invloc(lboundl(i),rank,i,i1) 
    1344          
    1345         do k=tab1(i)+lboundl(i)-i1,tab2(i)+lboundl(i)-i1 
    1346            tabarray(k-lboundl(i)+i1,i,1)=1 
    1347            tabarray(k-lboundl(i)+i1,i,2)=k 
    1348         enddo 
    1349  
    1350 C 
    1351       enddo 
    1352 C 
    1353       Return 
    1354 C 
    1355 C 
    1356       End Subroutine Agrif_GlobtoLocInd 
    1357  
    13581115C 
    13591116C     ************************************************************************** 
     
    14181175#endif       
    14191176 
     1177      Subroutine Agrif_Copy_2d(tabout,tabin,l,m,inf,sup,inf2,sup2) 
     1178      integer,dimension(2) :: l,m,inf,sup,inf2,sup2 
     1179      real,target,dimension(l(1):,l(2):) :: tabout 
     1180      real,target,dimension(m(1):,m(2):) :: tabin 
     1181          tabout(inf(1):sup(1), 
     1182     &                         inf(2):sup(2)) =  
     1183     &         tabin(inf2(1):sup2(1), 
     1184     &                          inf2(2):sup2(2)) 
     1185      End Subroutine Agrif_Copy_2d 
     1186       
     1187      Subroutine Agrif_Copy_3d(tabout,tabin,l,m,inf,sup,inf2,sup2) 
     1188      integer,dimension(3) :: l,m,inf,sup,inf2,sup2 
     1189      real,target,dimension(l(1):,l(2):,l(3):) :: tabout 
     1190      real,target,dimension(m(1):,m(2):,m(3):) :: tabin 
     1191          tabout(inf(1):sup(1), 
     1192     &                         inf(2):sup(2),  
     1193     &                         inf(3):sup(3)) =  
     1194     &         tabin(inf2(1):sup2(1), 
     1195     &                          inf2(2):sup2(2), 
     1196     &                          inf2(3):sup2(3)) 
     1197      End Subroutine Agrif_Copy_3d 
     1198       
     1199      Subroutine Agrif_Copy_4d(tabout,tabin,l,m,inf,sup,inf2,sup2) 
     1200      integer,dimension(4) :: l,m,inf,sup,inf2,sup2 
     1201      real,target,dimension(l(1):,l(2):,l(3):,l(4):) :: tabout 
     1202      real,target,dimension(m(1):,m(2):,m(3):,m(4):) :: tabin 
     1203          tabout(inf(1):sup(1), 
     1204     &                         inf(2):sup(2),  
     1205     &                         inf(3):sup(3),  
     1206     &                         inf(4):sup(4)) =  
     1207     &         tabin(inf2(1):sup2(1), 
     1208     &                          inf2(2):sup2(2), 
     1209     &                          inf2(3):sup2(3), 
     1210     &                          inf2(4):sup2(4)) 
     1211      End Subroutine Agrif_Copy_4d       
     1212 
    14201213      End Module Agrif_Arrays 
  • trunk/AGRIF/AGRIF_FILES/modbc.F

    r572 r662  
    9191      childtemp % var % interpIndex => child % var % interpIndex        
    9292      childtemp % var % Interpolationshouldbemade =  
    93      &                 child % var % Interpolationshouldbemade        
     93     &                 child % var % Interpolationshouldbemade   
     94      childtemp % var % list_interp => child % var% list_interp           
    9495C 
    9596C     Call to the procedure for the calculations of the boundary conditions 
     
    9899C 
    99100      child % var % oldvalues2D => childtemp % var % oldvalues2D 
     101      child % var % list_interp => childtemp % var %list_interp       
    100102C       
    101103      deallocate(childtemp % var) 
     
    159161      childtemp % var % interpIndex => child % var % interpIndex        
    160162      childtemp % var % Interpolationshouldbemade =  
    161      &                 child % var % Interpolationshouldbemade        
     163     &                 child % var % Interpolationshouldbemade    
     164      childtemp % var % list_interp => child % var% list_interp     
    162165C 
    163166C     Call to the procedure for the calculations of the boundary conditions 
     
    172175C    
    173176      child % var % oldvalues2D => childtemp % var % oldvalues2D 
     177      child % var % list_interp => childtemp % var %list_interp 
    174178C          
    175179      deallocate(childtemp % var) 
     
    234238      childtemp % var % interpIndex => child % var % interpIndex 
    235239      childtemp % var % Interpolationshouldbemade =  
    236      &                 child % var % Interpolationshouldbemade        
     240     &                 child % var % Interpolationshouldbemade  
     241      childtemp % var % list_interp => child % var% list_interp            
    237242C 
    238243C     Call to the procedure for the calculations of the boundary conditions      
     
    246251C 
    247252      child % var % oldvalues2D => childtemp % var % oldvalues2D 
     253      child % var % list_interp => childtemp % var %list_interp       
    248254C       
    249255      deallocate(childtemp % var) 
     
    310316      childtemp % var % interpIndex => child % var % interpIndex        
    311317      childtemp % var % Interpolationshouldbemade =  
    312      &                 child % var % Interpolationshouldbemade        
     318     &                 child % var % Interpolationshouldbemade   
     319      childtemp % var % list_interp => child % var% list_interp           
    313320C 
    314321C     Call to the procedure for the calculations of the boundary conditions 
     
    322329C 
    323330      child % var % oldvalues2D => childtemp % var % oldvalues2D 
     331      child % var % list_interp => childtemp % var %list_interp       
    324332C       
    325333      deallocate(childtemp % var) 
     
    386394      childtemp % var % interpIndex => child % var % interpIndex        
    387395      childtemp % var % Interpolationshouldbemade =  
    388      &                 child % var % Interpolationshouldbemade        
     396     &                 child % var % Interpolationshouldbemade  
     397      childtemp % var % list_interp => child % var% list_interp            
    389398C 
    390399C     Call to the procedure for the calculations of the boundary conditions   
     
    398407C 
    399408      child % var % oldvalues2D => childtemp % var % oldvalues2D 
     409      child % var % list_interp => childtemp % var %list_interp       
    400410C       
    401411      deallocate(childtemp % var) 
     
    462472      childtemp % var % interpIndex => child % var % interpIndex        
    463473      childtemp % var % Interpolationshouldbemade =  
    464      &                 child % var % Interpolationshouldbemade        
     474     &                 child % var % Interpolationshouldbemade  
     475      childtemp % var % list_interp => child % var% list_interp            
    465476C 
    466477C     Call to the procedure for the calculations of the boundary conditions 
     
    469480C 
    470481      child % var % oldvalues2D => childtemp % var % oldvalues2D 
     482      child % var % list_interp => childtemp % var %list_interp       
    471483C       
    472484      deallocate(childtemp % var) 
     
    744756                                       !   boundary conditions are  
    745757      INTEGER,DIMENSION(nbdim,2,2,nbdim)   :: ptres,ptres2 ! calculated 
    746       INTEGER                      :: nb,ndir,n,sizetab 
     758      INTEGER                      :: nb,ndir,n,sizetab(1) 
    747759      REAL, DIMENSION(:), Allocatable :: tab ! Array used for the interpolation 
    748       INTEGER, DIMENSION(nbdim)  :: ztab ! Array used for the interpolation 
    749760      REAL    :: c1t,c2t               ! Coefficients for the time interpolation 
    750761                                       !    (c2t=1-c1t)  
     
    772783        indtab(1:nbdim,1,2) = indtab(1:nbdim,1,2) - 1 
    773784      END WHERE 
     785       
    774786 
    775787#if !defined AGRIF_MPI 
     
    805817      indtruetab(1:nbdim,2,2) = min(indtab(1:nbdim,2,2), 
    806818     &     lubglob(1:nbdim,2)) 
    807                          
     819 
     820                               
    808821C  
    809822C 
     
    928941C                on the parent grid) 
    929942C       
    930               sizetab = 1 
    931               ztab(1) = ptres2(1,2,ndir,nb)-ptres2(1,1,ndir,nb)+1 
    932 C 
    933               do i = 2,nbdim 
     943              sizetab(1) = 1 
     944C 
     945              do i = 1,nbdim 
    934946C           
    935                 ztab(i) = ztab(i-1)  
     947                sizetab(1) = sizetab(1) 
    936948     &              * (ptres2(i,2,ndir,nb)-ptres2(i,1,ndir,nb)+1) 
    937949C       
    938950              enddo 
    939               sizetab=ztab(nbdim)   
    940               allocate(tab(sizetab)) 
    941 C 
    942              Call Agrif_vector2array( 
    943      &                      tab,child%var, 
    944      &                      ptres2(:,:,ndir,nb), 
    945      &                      nbdim) 
    946  
    947 C      
    948               Call saveAfterInterp 
    949      &             (child,tab,kindex) 
    950 C 
    951 C 
    952               deallocate(tab)      
     951 
     952              Call saveAfterInterp(child, 
     953     &           ptres2(:,:,ndir,nb),kindex,sizetab(1),nbdim) 
     954C 
    953955           ENDIF 
    954956C 
     
    992994          if (loctab_child(nb) /= (-ndir)  
    993995     &        .AND. loctab_child(nb) /= -3) then 
    994 C       
    995               sizetab=1   
    996               ztab(1) = ptres2(1,2,ndir,nb)-ptres2(1,1,ndir,nb)+1 
    997               do i = 2,nbdim 
    998 C           
    999                 ztab(i) = ztab(i-1) 
    1000      &             * (ptres2(i,2,ndir,nb)-ptres2(i,1,ndir,nb)+1) 
    1001 C       
    1002               enddo 
    1003 C               
    1004               sizetab = ztab(nbdim)  
    1005               allocate(tab(sizetab)) 
    1006 C 
    1007              Call Agrif_vector2array( 
    1008      &                      tab,child%var, 
    1009      &                      ptres2(:,:,ndir,nb), 
    1010      &                      nbdim) 
    1011 C     
    1012 C                   
     996 
    1013997              Call timeInterpolation 
    1014      &             (child,tab,kindex,c1t,c2t)            
    1015 C 
    1016 C 
    1017           Call Agrif_array2vector( 
    1018      &                   child%var, 
    1019      &                   ptres2(:,:,ndir,nb), 
    1020      &                   tab,nbdim) 
    1021 C 
    1022 C          
    1023               deallocate(tab) 
    1024 C  
     998     &             (child,ptres2(:,:,ndir,nb),kindex,c1t,c2t,nbdim) 
    1025999          endif 
    10261000C 
     
    10391013C     ************************************************************************** 
    10401014C 
    1041       Subroutine saveAfterInterp(child,tab,kindex) 
     1015      Subroutine saveAfterInterp(child,bounds,kindex,newsize,nbdim) 
    10421016C 
    10431017CCC   Descritpion: 
     
    10511025C     argument 
    10521026      TYPE (AGRIF_PVariable) :: child   ! The fine grid variable 
    1053       REAL, DIMENSION(:)     :: tab     ! Values on the fine grid variable  
    1054                                         !   after the space interpolation   
    10551027      INTEGER                :: kindex  ! Index indicating where this safeguard  
    10561028                                        ! is done on the fine grid 
     1029      INTEGER :: nbdim, newsize 
     1030      INTEGER,DIMENSION(nbdim,2) :: bounds 
    10571031C 
    10581032C     Local scalars 
    1059       INTEGER :: newsize                ! Size of the domain where boundary 
    1060                                         !    conditions are calculated 
    1061       INTEGER :: i 
     1033      INTEGER                      :: ir,jr,kr,lr,mr,nr 
    10621034C 
    10631035C 
    10641036C     Allocation of the array oldvalues2d 
    1065       newsize = size(tab) 
     1037 
    10661038C 
    10671039      if (newsize .LE. 0) return 
    10681040C 
    1069       Call checkSize 
     1041      Call Agrif_Checksize 
    10701042     &     (child,kindex+newsize)   
    1071 C 
    1072 C 
    1073 C     Safeguard in the oldvalues2d array        
    1074 C             
     1043 
    10751044      if (child % var % interpIndex  
    10761045     &        /= Agrif_Curgrid % parent % ngridstep ) then 
    1077          do i = 1,newsize 
    1078            child % var % oldvalues2d(kindex,1) = child % var % 
    1079      &                                        oldvalues2d(kindex,2)  
    1080            child % var % oldvalues2d(kindex,2) = tab(i) 
    1081            kindex = kindex + 1 
    1082          enddo 
    1083       else 
    1084         do i = 1,newsize 
    1085            child % var % oldvalues2d(kindex,2) = tab(i) 
    1086            kindex = kindex + 1 
    1087          enddo 
     1046       child%var%oldvalues2d(kindex:kindex+newsize-1,1)= 
     1047     &        child%var%oldvalues2d(kindex:kindex+newsize-1,2) 
    10881048      endif 
    1089       
    1090  
     1049 
     1050      SELECT CASE (nbdim) 
     1051      CASE (1) 
     1052 
     1053         do ir=bounds(1,1),bounds(1,2) 
     1054            child%var%oldvalues2d(kindex,2) = 
     1055     &           child%var%array1(ir) 
     1056            kindex = kindex + 1 
     1057         enddo        
     1058C 
     1059      CASE (2) 
     1060 
     1061        do jr=bounds(2,1),bounds(2,2) 
     1062           do ir=bounds(1,1),bounds(1,2) 
     1063            child%var%oldvalues2d(kindex,2) = 
     1064     &           child%var%array2(ir,jr) 
     1065            kindex = kindex + 1 
     1066           enddo 
     1067         enddo       
     1068C 
     1069      CASE (3) 
     1070        do kr=bounds(3,1),bounds(3,2) 
     1071          do jr=bounds(2,1),bounds(2,2) 
     1072             do ir=bounds(1,1),bounds(1,2) 
     1073            child%var%oldvalues2d(kindex,2) = 
     1074     &           child%var%array3(ir,jr,kr) 
     1075            kindex = kindex + 1 
     1076             enddo 
     1077           enddo 
     1078         enddo        
     1079C 
     1080      CASE (4) 
     1081          do lr=bounds(4,1),bounds(4,2) 
     1082           do kr=bounds(3,1),bounds(3,2) 
     1083             do jr=bounds(2,1),bounds(2,2) 
     1084               do ir=bounds(1,1),bounds(1,2) 
     1085            child%var%oldvalues2d(kindex,2) = 
     1086     &           child%var%array4(ir,jr,kr,lr) 
     1087            kindex = kindex + 1 
     1088               enddo 
     1089             enddo 
     1090           enddo 
     1091         enddo          
     1092C 
     1093      CASE (5) 
     1094         do mr=bounds(5,1),bounds(5,2) 
     1095           do lr=bounds(4,1),bounds(4,2) 
     1096            do kr=bounds(3,1),bounds(3,2)  
     1097              do jr=bounds(2,1),bounds(2,2) 
     1098                 do ir=bounds(1,1),bounds(1,2) 
     1099            child%var%oldvalues2d(kindex,2) = 
     1100     &           child%var%array5(ir,jr,kr,lr,mr) 
     1101            kindex = kindex + 1 
     1102                 enddo 
     1103               enddo 
     1104             enddo 
     1105           enddo 
     1106         enddo    
     1107C 
     1108      CASE (6) 
     1109        do nr=bounds(6,1),bounds(6,2) 
     1110           do mr=bounds(5,1),bounds(5,2) 
     1111             do lr=bounds(4,1),bounds(4,2) 
     1112               do kr=bounds(3,1),bounds(3,2) 
     1113                do jr=bounds(2,1),bounds(2,2) 
     1114                   do ir=bounds(1,1),bounds(1,2) 
     1115            child%var%oldvalues2d(kindex,2) = 
     1116     &           child%var%array6(ir,jr,kr,lr,mr,nr) 
     1117            kindex = kindex + 1 
     1118                   enddo 
     1119                 enddo 
     1120               enddo 
     1121             enddo 
     1122           enddo 
     1123         enddo        
     1124      END SELECT 
    10911125C 
    10921126C                                                   
     
    10991133C     ************************************************************************** 
    11001134C 
    1101       Subroutine timeInterpolation(child,tab,kindex,c1t,c2t)  
     1135      Subroutine timeInterpolation(child,bounds,kindex,c1t,c2t,nbdim)  
    11021136C 
    11031137CCC   Descritpion: 
     
    11101144C     argument 
    11111145      TYPE (AGRIF_PVariable) :: child  ! The fine grid variable 
    1112       REAL, DIMENSION(:)     :: tab 
     1146      INTEGER :: nbdim 
     1147      INTEGER,DIMENSION(nbdim,2) :: bounds 
    11131148      INTEGER                :: kindex ! Index indicating the values of the fine 
    11141149                                       ! grid got before and after the space  
     
    11201155C     Local aruments       
    11211156      INTEGER :: i 
    1122 C 
    1123 C 
    1124       do i = 1,size(tab) 
    1125         tab(i) = c2t*child % var % oldvalues2d(kindex,1)    
    1126      &         + c1t*child % var % oldvalues2d(kindex,2)         
    1127         kindex = kindex + 1         
    1128       enddo                                              
     1157C     Local scalars 
     1158      INTEGER                      :: ir,jr,kr,lr,mr,nr       
     1159C 
     1160C 
     1161       
     1162      SELECT CASE (nbdim) 
     1163      CASE (1) 
     1164 
     1165         do ir=bounds(1,1),bounds(1,2) 
     1166                child%var%array1(ir) = 
     1167     &           c2t*child % var % oldvalues2d(kindex,1)    
     1168     &         + c1t*child % var % oldvalues2d(kindex,2)     
     1169            kindex = kindex + 1 
     1170         enddo        
     1171C 
     1172      CASE (2) 
     1173 
     1174        do jr=bounds(2,1),bounds(2,2) 
     1175           do ir=bounds(1,1),bounds(1,2) 
     1176                child%var%array2(ir,jr) = 
     1177     &           c2t*child % var % oldvalues2d(kindex,1)    
     1178     &         + c1t*child % var % oldvalues2d(kindex,2)  
     1179            kindex = kindex + 1 
     1180           enddo 
     1181         enddo       
     1182C 
     1183      CASE (3) 
     1184        do kr=bounds(3,1),bounds(3,2) 
     1185          do jr=bounds(2,1),bounds(2,2) 
     1186             do ir=bounds(1,1),bounds(1,2) 
     1187                child%var%array3(ir,jr,kr) = 
     1188     &           c2t*child % var % oldvalues2d(kindex,1)    
     1189     &         + c1t*child % var % oldvalues2d(kindex,2)  
     1190            kindex = kindex + 1 
     1191             enddo 
     1192           enddo 
     1193         enddo        
     1194C 
     1195      CASE (4) 
     1196          do lr=bounds(4,1),bounds(4,2) 
     1197           do kr=bounds(3,1),bounds(3,2) 
     1198             do jr=bounds(2,1),bounds(2,2) 
     1199               do ir=bounds(1,1),bounds(1,2) 
     1200                child%var%array4(ir,jr,kr,lr) = 
     1201     &           c2t*child % var % oldvalues2d(kindex,1)    
     1202     &         + c1t*child % var % oldvalues2d(kindex,2)  
     1203            kindex = kindex + 1 
     1204               enddo 
     1205             enddo 
     1206           enddo 
     1207         enddo          
     1208C 
     1209      CASE (5) 
     1210         do mr=bounds(5,1),bounds(5,2) 
     1211           do lr=bounds(4,1),bounds(4,2) 
     1212            do kr=bounds(3,1),bounds(3,2)  
     1213              do jr=bounds(2,1),bounds(2,2) 
     1214                 do ir=bounds(1,1),bounds(1,2) 
     1215                child%var%array5(ir,jr,kr,lr,mr) = 
     1216     &           c2t*child % var % oldvalues2d(kindex,1)    
     1217     &         + c1t*child % var % oldvalues2d(kindex,2)  
     1218            kindex = kindex + 1 
     1219                 enddo 
     1220               enddo 
     1221             enddo 
     1222           enddo 
     1223         enddo    
     1224C 
     1225      CASE (6) 
     1226        do nr=bounds(6,1),bounds(6,2) 
     1227           do mr=bounds(5,1),bounds(5,2) 
     1228             do lr=bounds(4,1),bounds(4,2) 
     1229               do kr=bounds(3,1),bounds(3,2) 
     1230                do jr=bounds(2,1),bounds(2,2) 
     1231                   do ir=bounds(1,1),bounds(1,2) 
     1232                child%var%array6(ir,jr,kr,lr,mr,nr) = 
     1233     &           c2t*child % var % oldvalues2d(kindex,1)    
     1234     &         + c1t*child % var % oldvalues2d(kindex,2)  
     1235            kindex = kindex + 1 
     1236                   enddo 
     1237                 enddo 
     1238               enddo 
     1239             enddo 
     1240           enddo 
     1241         enddo        
     1242      END SELECT 
     1243                                                    
    11291244C 
    11301245C 
     
    11341249C 
    11351250C     ************************************************************************** 
    1136 CCC   Subroutine checkSize 
    1137 C     ************************************************************************** 
    1138 C 
    1139       Subroutine checkSize(child,newsize) 
     1251CCC   Subroutine Agrif_Checksize 
     1252C     ************************************************************************** 
     1253C 
     1254      Subroutine Agrif_Checksize(child,newsize) 
    11401255C 
    11411256CCC   Descritpion: 
     
    11891304C 
    11901305C 
    1191       End  Subroutine checkSize 
     1306      End  Subroutine Agrif_Checksize 
    11921307C 
    11931308C 
  • trunk/AGRIF/AGRIF_FILES/modbcfunction.F

    r396 r662  
    3434      Use Agrif_Boundary 
    3535      Use Agrif_Update 
     36      Use Agrif_fluxmod 
    3637C              
    3738      IMPLICIT NONE 
     
    109110      dimensio = Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim 
    110111C 
     112      if (.not.associated(Agrif_Mygrid % tabvars(tabvarsindic) 
     113     &                                 %var % posvar)) then 
    111114      Allocate(  
    112115     & Agrif_Mygrid % tabvars(tabvarsindic)%var % posvar(dimensio)) 
    113  
     116      endif  
     117             
    114118      do i = 1 , dimensio 
    115119         Agrif_Mygrid % tabvars(tabvarsindic) %var % posvar(i) 
     
    214218C 
    215219      dimensio = Agrif_Mygrid % tabvars(tabvarsindic) %var % nbdim 
    216 C          
     220C         
     221      if (.not.associated(Agrif_Mygrid % tabvars(tabvarsindic) 
     222     &                                 %var % interptab)) then  
    217223      Allocate( 
    218224     & Agrif_Mygrid % tabvars(tabvarsindic)%var% interptab(dimensio)) 
     225      endif 
    219226 
    220227      do i = 1 , dimensio 
     
    254261C 
    255262C      
    256       if (Agrif_Curgrid % fixedrank .NE. 0) then     
    257       allocate(Agrif_Curgrid%tabvars(tabvarsindic)%var % interpIndex) 
    258       Agrif_Curgrid%tabvars(tabvarsindic)%var % interpIndex = -1 
    259       if ( PRESENT(Interpolationshouldbemade) ) then 
     263      if (Agrif_Curgrid % fixedrank .NE. 0) then   
     264       IF (.Not.Associated(Agrif_Curgrid%tabvars(tabvarsindic)%var 
     265     &                % interpIndex)) THEN 
     266        Allocate(Agrif_Curgrid%tabvars(tabvarsindic)%var % interpIndex) 
     267          Agrif_Curgrid%tabvars(tabvarsindic)%var % interpIndex = -1 
     268 
     269        Allocate( 
     270     &    Agrif_Curgrid%tabvars(tabvarsindic)%var % oldvalues2D(1,2)) 
     271          Agrif_Curgrid%tabvars(tabvarsindic)%var % oldvalues2D = 0.  
     272       ENDIF       
     273       if ( PRESENT(Interpolationshouldbemade) ) then 
    260274         Agrif_Curgrid%tabvars(tabvarsindic)%var % 
    261275     &     Interpolationshouldbemade = Interpolationshouldbemade 
    262       endif 
    263       Allocate( 
    264      & Agrif_Curgrid%tabvars(tabvarsindic)%var % oldvalues2D(1,2)) 
    265       Agrif_Curgrid%tabvars(tabvarsindic)%var % oldvalues2D = 0.  
     276       endif 
     277 
    266278      endif 
    267279C 
     
    591603     & weight,pweight,procname) 
    592604      ELSE 
     605           
    593606      Call Agrif_Interp_Bc_2D( 
    594607     & Agrif_Mygrid % tabvars(tabvarsindic) % var % bctypeinterp, 
     
    14181431 
    14191432      Return 
    1420       End Subroutine Agrif_update_var5d           
     1433      End Subroutine Agrif_update_var5d   
     1434           
     1435      Subroutine Agrif_Declare_Flux(fluxname,profilename)  
     1436      character*(*) :: fluxname, profilename 
     1437      Type(Agrif_Flux), pointer :: newflux 
     1438      Type(Agrif_Profile), pointer  :: parcours 
     1439      logical :: foundprofile 
     1440      integer :: i,j,n 
     1441             
     1442      foundprofile = .FALSE. 
     1443      parcours => Agrif_Myprofiles 
     1444       
     1445      Do While (Associated(parcours)) 
     1446         IF (parcours % profilename == profilename) THEN 
     1447           foundprofile = .TRUE. 
     1448           EXIT 
     1449         ENDIF 
     1450         parcours => parcours%nextprofile 
     1451      End Do       
     1452       
     1453      IF (.NOT.foundprofile) THEN 
     1454      write(*,*) 'The profile ''' 
     1455     &           //TRIM(profilename)//''' has not been declared'   
     1456      stop     
     1457      ENDIF 
     1458       
     1459      print *,'ici' 
     1460      Allocate(Newflux) 
     1461       
     1462      Newflux % fluxname = fluxname 
     1463       
     1464      Newflux % profile => parcours 
     1465       
     1466      Newflux % nextflux => Agrif_Curgrid % fluxes 
     1467       
     1468      Agrif_Curgrid % fluxes => Newflux 
     1469       
     1470      End Subroutine Agrif_Declare_Flux   
     1471        
     1472      Subroutine Agrif_Save_Flux(fluxname, fluxtab) 
     1473      character*(*) :: fluxname 
     1474      REAL, DIMENSION(:,:) :: fluxtab 
     1475       
     1476       
     1477      Type(Agrif_Flux), pointer :: Flux 
     1478       
     1479      Type(Agrif_pgrid), pointer :: parcours_child 
     1480       
     1481      Type(Agrif_grid), Pointer :: currentgrid,oldcurgrid 
     1482       
     1483      IF (.Not.Agrif_Root()) THEN 
     1484      Flux => Agrif_Search_Flux(fluxname) 
     1485 
     1486      IF (.NOT.Flux%fluxallocated) THEN 
     1487        CALL Agrif_AllocateFlux(Flux,fluxtab) 
     1488      ENDIF 
     1489       
     1490      Call Agrif_Save_Fluxtab(Flux,fluxtab) 
     1491       
     1492      ENDIF 
     1493       
     1494      oldcurgrid=> Agrif_Curgrid 
     1495       
     1496      parcours_child => Agrif_Curgrid%child_grids 
     1497       
     1498      Do While (Associated(parcours_child)) 
     1499        currentgrid => parcours_child%gr 
     1500        Agrif_Curgrid => parcours_child%gr 
     1501        Flux => Agrif_Search_Flux(fluxname) 
     1502        IF (.NOT.Flux%fluxallocated) THEN 
     1503          CALL Agrif_AllocateFlux(Flux,fluxtab) 
     1504        ENDIF         
     1505        Call Agrif_Save_Fluxtab_child(Flux,fluxtab) 
     1506        parcours_child=> parcours_child%next 
     1507      End Do 
     1508       
     1509      Agrif_Curgrid=>oldcurgrid 
     1510       
     1511      End Subroutine Agrif_Save_Flux 
     1512 
     1513      Subroutine Agrif_Cancel_Flux(fluxname) 
     1514      character*(*) :: fluxname 
     1515       
     1516      Type(Agrif_Flux), pointer :: Flux 
     1517       
     1518      Flux => Agrif_Search_Flux(fluxname) 
     1519 
     1520      IF (Flux%FluxAllocated) Call Agrif_Cancel_Fluxarray(Flux) 
     1521       
     1522      End Subroutine Agrif_Cancel_Flux 
     1523  
     1524      Subroutine Agrif_Flux_Correction(fluxname, procname) 
     1525      character*(*) :: fluxname 
     1526      external :: procname 
     1527       
     1528      Type(Agrif_Flux), pointer :: Flux 
     1529       
     1530      Flux => Agrif_Search_Flux(fluxname) 
     1531       
     1532      Call Agrif_FluxCorrect(Flux, procname) 
     1533 
     1534       
     1535      End Subroutine Agrif_Flux_Correction 
     1536                   
     1537      Subroutine Agrif_Declare_Profile(profilename,posvar,firstpoint, 
     1538     &    raf) 
     1539      character*(*) :: profilename 
     1540      Type(Agrif_Profile), Pointer :: newprofile 
     1541      INTEGER, DIMENSION(:) :: posvar 
     1542      INTEGER, DIMENSION(:) :: firstpoint 
     1543      CHARACTER(*) ,DIMENSION(:) :: raf       
     1544      INTEGER :: dimensio 
     1545             
     1546      dimensio = SIZE(posvar) 
     1547C 
     1548C     
     1549      Allocate(newprofile) 
     1550      Allocate(newprofile%posvar(dimensio)) 
     1551      Allocate(newprofile%interptab(dimensio)) 
     1552      newprofile%profilename = profilename 
     1553      newprofile%interptab = raf 
     1554      newprofile%nbdim = dimensio 
     1555      newprofile%posvar = posvar 
     1556      newprofile%point(1:dimensio) = firstpoint 
     1557       
     1558      newprofile % nextprofile => Agrif_myprofiles 
     1559       
     1560      Agrif_myprofiles => newprofile 
     1561       
     1562      End Subroutine Agrif_Declare_Profile 
     1563               
    14211564C 
    14221565      End module Agrif_bcfunction 
  • trunk/AGRIF/AGRIF_FILES/modcluster.F

    r396 r662  
    131131C 
    132132C       Recursive call to Agrif_Cluster_All             
    133         Call Agrif_Cluster_All (newgrid, parcours % r)        
     133        Call Agrif_Cluster_All (newgrid, parcours % r)      
    134134C 
    135135        parcours => parcours % next  
     
    574574C coefficient 1.05 avant 1.15 possibilité de laisser choix à l utilisateur 
    575575                  if  (REAL(nbpointsflag)/REAL(nbpoints) 
    576      &                 .LT.(1.05*cureff)) then 
     576     &                 .LT.(1.0001*cureff)) then 
    577577                      parcbox2 => boxlib             
    578578                      do While (associated(parcbox2)) 
  • trunk/AGRIF/AGRIF_FILES/modcurgridfunctions.F

    r396 r662  
    779779C 
    780780      End Function Agrif_Get_Unit 
     781       
     782      Subroutine Agrif_Set_Efficiency(eff) 
     783      REAL :: eff 
     784       
     785      IF ((eff.LT.0.).OR.(eff.GT.1)) THEN 
     786      write(*,*)'Error Efficiency should be between 0 and 1' 
     787      stop 
     788      ELSE 
     789      Agrif_efficiency = eff 
     790      ENDIF 
     791      End Subroutine Agrif_Set_Efficiency 
     792       
     793      Subroutine Agrif_Set_Regridding(regfreq) 
     794      INTEGER :: regfreq 
     795       
     796      IF (regfreq.LT.0) THEN 
     797      write(*,*)'Regridding frequency should be positive' 
     798      stop 
     799      ELSE 
     800      Agrif_regridding = regfreq 
     801      ENDIF 
     802      End Subroutine Agrif_Set_Regridding 
    781803C 
    782804      End Module Agrif_CurgridFunctions  
  • trunk/AGRIF/AGRIF_FILES/modinterp.F

    r396 r662  
    104104      childtemp % var % interpIndex => child % var % interpIndex        
    105105      childtemp % var % Interpolationshouldbemade =  
    106      &    child % var % Interpolationshouldbemade        
     106     &    child % var % Interpolationshouldbemade  
     107      childtemp % var % list_interp => child % var% list_interp             
    107108C       
    108109      Call Agrif_InterpVariable 
    109110     &     (TypeInterp,parent,childtemp,torestore) 
     111      child % var % list_interp => childtemp % var %list_interp      
    110112C       
    111113      deallocate(childtemp % var) 
     
    173175      childtemp % var % interpIndex => child % var % interpIndex        
    174176      childtemp % var % Interpolationshouldbemade =  
    175      &    child % var % Interpolationshouldbemade        
     177     &    child % var % Interpolationshouldbemade    
     178      childtemp % var % list_interp => child % var% list_interp           
    176179C      
    177180      Call Agrif_InterpVariable 
    178181     &     (TypeInterp,parent,childtemp,torestore) 
     182      child % var % list_interp => childtemp % var %list_interp      
    179183C       
    180184      deallocate(childtemp % var) 
     
    243247      childtemp % var % interpIndex => child % var % interpIndex     
    244248      childtemp % var % Interpolationshouldbemade =  
    245      &    child % var % Interpolationshouldbemade        
     249     &    child % var % Interpolationshouldbemade    
     250      childtemp % var % list_interp => child % var% list_interp           
    246251C      
    247252      Call Agrif_InterpVariable 
    248253     &     (TypeInterp,parent,childtemp,torestore) 
     254      child % var % list_interp => childtemp % var %list_interp      
    249255C       
    250256      deallocate(childtemp % var) 
     
    314320      childtemp % var % interpIndex => child % var % interpIndex     
    315321      childtemp % var % Interpolationshouldbemade =  
    316      &    child % var % Interpolationshouldbemade        
     322     &    child % var % Interpolationshouldbemade   
     323      childtemp % var % list_interp => child % var% list_interp            
    317324C      
    318325      Call Agrif_InterpVariable 
    319326     &     (TypeInterp,parent,childtemp,torestore) 
     327      child % var % list_interp => childtemp % var %list_interp 
    320328C       
    321329      deallocate(childtemp % var) 
     
    386394      childtemp % var % interpIndex => child % var % interpIndex     
    387395      childtemp % var % Interpolationshouldbemade =  
    388      &    child % var % Interpolationshouldbemade        
     396     &    child % var % Interpolationshouldbemade    
     397      childtemp % var % list_interp => child % var% list_interp           
    389398C       
    390399      Call Agrif_InterpVariable 
    391400     &     (TypeInterp,parent,childtemp,torestore) 
     401      
     402      child % var % list_interp => childtemp % var %list_interp 
    392403C       
    393404      deallocate(childtemp % var) 
     
    459470      childtemp % var % interpIndex => child % var % interpIndex     
    460471      childtemp % var % Interpolationshouldbemade =  
    461      &    child % var % Interpolationshouldbemade        
     472     &    child % var % Interpolationshouldbemade   
     473      
     474      childtemp % var % list_interp => child % var% list_interp            
    462475C       
    463476      Call Agrif_InterpVariable 
    464477     &     (TypeInterp,parent,childtemp,torestore) 
    465478C       
     479      child % var % list_interp => childtemp % var %list_interp 
    466480      deallocate(childtemp % var) 
    467481C 
     
    591605C 
    592606C     Local pointers 
    593       TYPE(AGRIF_PVARIABLE)      :: tempP,tempPextend  ! Temporary parent grid variable 
    594       TYPE(AGRIF_PVARIABLE)      :: tempC      ! Temporary child grid variable 
     607      TYPE(AGRIF_PVARIABLE),SAVE      :: tempP,tempPextend  ! Temporary parent grid variable 
     608      TYPE(AGRIF_PVARIABLE),SAVE      :: tempC      ! Temporary child grid variable 
    595609C 
    596610C     Local scalars         
     
    605619      INTEGER,DIMENSION(nbdim,2,2) :: parentarray 
    606620      LOGICAL :: memberin,member 
    607       TYPE(AGRIF_PVARIABLE)                      ::  parentvalues 
     621      TYPE(AGRIF_PVARIABLE),SAVE                      ::  parentvalues 
     622      LOGICAL :: find_list_interp 
     623      INTEGER,DIMENSION(nbdim)    :: indminglob2,indmaxglob2       
    608624C 
    609625#ifdef AGRIF_MPI 
     
    612628      INTEGER,PARAMETER                          :: etiquette = 100 
    613629      INTEGER                                    :: code 
    614       INTEGER,DIMENSION(nbdim)    :: indminglob2,indmaxglob2 
    615630      INTEGER,DIMENSION(nbdim,4)           :: tab3 
    616631      INTEGER,DIMENSION(nbdim,4,0:Agrif_Nbprocs-1) :: tab4 
    617632      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,4) :: tab4t 
     633      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: memberinall 
     634      LOGICAL, DIMENSION(1) :: memberin1 
    618635C 
    619636#endif       
     
    621638C    
    622639C     Boundaries of the current grid where interpolation is done 
     640 
     641       
     642       
     643       
     644      IF (Associated(child%var%list_interp)) THEN 
     645      Call Agrif_Find_list_interp(child%var%list_interp,pttab,petab, 
     646     &                          pttab_Child,pttab_Parent,nbdim, 
     647     &                          indmin,indmax,indminglob, 
     648     &       indmaxglob,indminglob2,indmaxglob2,parentarray, 
     649     &       pttruetab,cetruetab,member,memberin,find_list_interp 
     650#if defined AGRIF_MPI 
     651     &       ,tab4t,memberinall 
     652#endif 
     653     &    ) 
     654      ELSE 
     655      find_list_interp = .FALSE. 
     656      ENDIF 
     657       
     658      IF (.not.find_list_interp) THEN 
    623659      Call Agrif_nbdim_Get_bound_dimension(child % var, 
    624660     &                               lowerbound,upperbound,nbdim) 
     
    627663     &                                   pttab,petab, 
    628664     &                                   pttruetab,cetruetab,memberin) 
     665      
    629666C 
    630667C 
     
    640677 
    641678 
    642 #ifdef AGRIF_MPI  
    643  
    644       IF (memberin) THEN 
    645       Call Agrif_Parentbounds(TYPEinterp,nbdim,indmin,indmax, 
     679#ifdef AGRIF_MPI 
     680       IF (memberin) THEN 
     681        Call Agrif_Parentbounds(TYPEinterp,nbdim,indmin,indmax, 
    646682     &                        s_Parent_temp,s_Child_temp, 
    647683     &                        s_Child,ds_Child, 
     
    651687     &                        child%var%root_var%posvar, 
    652688     &                        child % var % root_var % interptab) 
    653       ENDIF 
    654     
     689      ENDIF  
    655690 
    656691      Call Agrif_nbdim_Get_bound_dimension(parent%var, 
     
    671706     &                     nbdim,Agrif_Procrank, 
    672707     &                     member) 
    673             endif 
    674  
     708       endif 
     709        
    675710      Call Agrif_ParentGrid_to_ChildGrid() 
    676711#else 
     
    684719#endif 
    685720 
     721      ELSE 
     722       
     723#if !defined AGRIF_MPI 
     724      parentarray(:,1,1) = indminglob 
     725      parentarray(:,2,1) = indmaxglob 
     726      parentarray(:,1,2) = indminglob 
     727      parentarray(:,2,2) = indmaxglob 
     728      indmin = indminglob 
     729      indmax = indmaxglob 
     730      member = .TRUE. 
     731      s_Parent_temp = s_Parent + (indminglob - pttab_Parent)*ds_Parent 
     732      s_Child_temp = s_Child + (pttab - pttab_Child) * ds_Child 
     733#else       
     734      s_Parent_temp = s_Parent + (indmin - pttab_Parent)*ds_Parent 
     735      s_Child_temp = s_Child + (pttruetab - pttab_Child) * ds_Child 
     736#endif       
     737            
     738      ENDIF 
     739 
    686740 
    687741 
    688742      IF (member) THEN 
    689       allocate(tempP%var) 
     743      IF (.not.associated(tempP%var)) allocate(tempP%var) 
    690744 
    691745C 
     
    736790      Call Agrif_ParentGrid_to_ChildGrid() 
    737791      ELSE 
     792 
    738793      Call Agrif_nbdim_VarEQvar(tempP%var, 
    739794     &        parentarray(:,1,1),parentarray(:,2,1), 
     
    744799 
    745800#ifdef AGRIF_MPI 
     801      if (.not.find_list_interp) then 
    746802      tab3(:,1) = indminglob2(:) 
    747803      tab3(:,2) = indmaxglob2(:) 
     
    753809     &                   MPI_INTEGER,MPI_COMM_WORLD,code) 
    754810 
    755       Allocate(tempPextend%var) 
     811      IF (.not.associated(tempPextend%var)) Allocate(tempPextend%var) 
     812 
    756813      DO k=0,Agrif_Nbprocs-1 
    757814       do j=1,4 
     
    761818      enddo 
    762819      enddo 
     820       
     821      memberin1(1) = memberin 
     822      CALL MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall, 
     823     &                  1,MPI_LOGICAL,MPI_COMM_WORLD,code) 
     824      
     825      endif      
     826            
    763827      Call Get_External_Data(tempP,tempPextend,tab4t(:,:,1), 
    764828     &            tab4t(:,:,2), 
    765      &            tab4t(:,:,3),tab4t(:,:,4),nbdim,member,memberin) 
     829     &            tab4t(:,:,3),tab4t(:,:,4),nbdim,member,memberin, 
     830     &            memberinall) 
    766831#else 
    767832      tempPextend%var => tempP%var 
    768833#endif 
    769834 
     835      if (.not.find_list_interp) then 
     836      Call Agrif_Addto_list_interp(child%var%list_interp,pttab,petab, 
     837     &                          pttab_Child,pttab_Parent,indmin,indmax, 
     838     &   indminglob,indmaxglob,indminglob2,indmaxglob2,parentarray, 
     839     &   pttruetab,cetruetab,member,memberin,nbdim 
     840#if defined AGRIF_MPI 
     841     &   ,tab4t,memberinall 
     842#endif 
     843     &    ) 
     844      endif 
     845       
    770846C 
    771847C 
    772848      IF (memberin) THEN 
    773       allocate(tempC%var) 
     849      IF (.not.associated(tempC%var)) allocate(tempC%var) 
    774850C 
    775851 
     
    784860     &         child % var % root_var % interptab(1:nbdim) .EQ. 'N' 
    785861C 
    786           Allocate(parentvalues%var) 
     862          IF (.not.associated(parentvalues%var)) 
     863     &            Allocate(parentvalues%var) 
    787864C 
    788865          Call Agrif_nbdim_allocation 
     
    798875C 
    799876          Call Agrif_nbdim_deallocation(parentvalues%var,nbdim) 
    800           Deallocate(parentvalues%var) 
     877C          Deallocate(parentvalues%var) 
    801878C 
    802879C 
     
    9991076        CASE (2) 
    10001077           do j = pttruetab(2),cetruetab(2) 
    1001              do i = pttruetab(1),cetruetab(1)     
    1002               if (restore%var%restore2D(i,j) == 0) 
     1078             do i = pttruetab(1),cetruetab(1)             
     1079              if (restore%var%restore2D(i,j) == 0)      
    10031080     &              child % var % array2(i,j) =  
    10041081     &              tempC % var % array2(i,j)     
     
    11211198 
    11221199        Call Agrif_nbdim_deallocation(tempPextend%var,nbdim) 
    1123         deallocate(tempPextend%var) 
     1200C        deallocate(tempPextend%var) 
    11241201 
    11251202      Call Agrif_nbdim_deallocation(tempC%var,nbdim) 
    11261203       
    1127       Deallocate(tempC % var) 
     1204C      Deallocate(tempC % var) 
    11281205      ELSE 
    11291206       
    1130       deallocate(tempPextend%var) 
     1207C      deallocate(tempPextend%var) 
    11311208 
    11321209      ENDIF 
     
    11371214      IF (member) THEN 
    11381215      Call Agrif_nbdim_deallocation(tempP%var,nbdim) 
    1139       Deallocate(tempP % var) 
     1216C      Deallocate(tempP % var) 
    11401217      endif 
    11411218#endif 
     
    11691246C     Declarations: 
    11701247C 
    1171        
    1172 C 
    1173 #ifdef AGRIF_MPI 
    1174 C 
    1175 ccccccccccccccccccccccc#include "mpif.h" 
    1176 C 
    1177 #endif 
    11781248C 
    11791249C     Arguments 
     
    12141284        ELSEIF (interptab(i) .EQ. 'N') THEN 
    12151285        ELSEIF ( TYPEinterp(i) .eq. Agrif_ppm .or. 
    1216      &      TYPEinterp(i) .eq. Agrif_eno ) THEN             
     1286     &      TYPEinterp(i) .eq. Agrif_eno  .or. 
     1287     &      TYPEinterp(i) .eq. Agrif_weno) THEN             
    12171288           indmin(i) = indmin(i) - 2   
    12181289           indmax(i) = indmax(i) + 2                   
    1219         ELSE IF( TYPEinterp(i) .ne. Agrif_constant ) THEN 
     1290        ELSE IF (( TYPEinterp(i) .ne. Agrif_constant ) 
     1291     &        .AND.( TYPEinterp(i) .ne. Agrif_linear )) THEN 
    12201292           indmin(i) = indmin(i) - 1   
    12211293           indmax(i) = indmax(i) + 1 
     
    12621334      REAL, DIMENSION(nbdim) :: s_child,s_parent 
    12631335      REAL, DIMENSION(nbdim) :: ds_child,ds_parent 
    1264       REAL, DIMENSION(indmin(nbdim):indmax(nbdim)) :: tabin         
    1265       REAL, DIMENSION(pttab_child(nbdim):petab_child(nbdim)) :: tabout 
     1336      REAL, INTENT(IN),DIMENSION(indmin(nbdim):indmax(nbdim)) :: tabin         
     1337      REAL, INTENT(OUT), 
     1338     &      DIMENSION(pttab_child(nbdim):petab_child(nbdim)) :: tabout 
     1339      INTEGER :: coeffraf 
    12661340C 
    12671341C 
    12681342C     Commentaire perso : nbdim vaut toujours 1 ici.  
    12691343C 
     1344      coeffraf = nint(ds_parent(nbdim)/ds_child(nbdim)) 
     1345       
    12701346      Call Agrif_InterpBase(TypeInterp(1), 
    12711347     &                  tabin(indmin(nbdim):indmax(nbdim)), 
     
    12741350     &                  pttab_child(nbdim),petab_child(nbdim), 
    12751351     &                  s_parent(nbdim),s_child(nbdim), 
    1276      &                  ds_parent(nbdim),ds_child(nbdim)) 
     1352     &                  ds_parent(nbdim),ds_child(nbdim),coeffraf) 
    12771353C                 
    12781354      Return 
     
    13091385      REAL   , DIMENSION(nbdim) ::  s_child, s_parent 
    13101386      REAL   , DIMENSION(nbdim) :: ds_child,ds_parent 
    1311       REAL   , DIMENSION( 
     1387      REAL   ,INTENT(IN), DIMENSION( 
    13121388     &                indmin(nbdim-1):indmax(nbdim-1), 
    13131389     &                indmin(nbdim):indmax(nbdim) 
    13141390     &                ) :: tabin         
    1315       REAL   , DIMENSION( 
     1391      REAL   ,INTENT(OUT), DIMENSION( 
    13161392     &                pttab_child(nbdim-1):petab_child(nbdim-1), 
    13171393     &                pttab_child(nbdim):petab_child(nbdim) 
     
    13191395C 
    13201396C     Local variables       
    1321       REAL, DIMENSION(:,:), Allocatable :: tabtemp 
     1397      REAL, DIMENSION(pttab_child(nbdim-1):petab_child(nbdim-1), 
     1398     &                 indmin(nbdim):indmax(nbdim)) :: tabtemp 
    13221399      INTEGER i,j 
    1323 C 
    1324 C         
    1325       Allocate(tabtemp(pttab_child(nbdim-1):petab_child(nbdim-1), 
    1326      &                 indmin(nbdim):indmax(nbdim))) 
     1400      INTEGER :: coeffraf 
     1401C 
     1402C 
    13271403C 
    13281404C 
     
    13411417      enddo 
    13421418C         
     1419      coeffraf = nint(ds_parent(nbdim)/ds_child(nbdim)) 
     1420       
    13431421      do i=pttab_child(nbdim-1),petab_child(nbdim-1) 
    13441422C 
     
    13491427     &           pttab_child(nbdim),petab_child(nbdim), 
    13501428     &           s_parent(nbdim),s_child(nbdim), 
    1351      &           ds_parent(nbdim),ds_child(nbdim)) 
     1429     &           ds_parent(nbdim),ds_child(nbdim),coeffraf) 
    13521430C         
    13531431      enddo 
    1354 C                 
    1355       Deallocate(tabtemp) 
    13561432C 
    13571433      Return 
     
    13841460      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child 
    13851461      REAL, DIMENSION(nbdim) :: s_child,s_parent,ds_child,ds_parent 
    1386       REAL, DIMENSION(indmin(nbdim-2):indmax(nbdim-2), 
     1462      REAL,INTENT(IN), DIMENSION(indmin(nbdim-2):indmax(nbdim-2), 
    13871463     &                indmin(nbdim-1):indmax(nbdim-1), 
    13881464     &                indmin(nbdim)  :indmax(nbdim)) :: tabin         
    1389       REAL, DIMENSION(pttab_child(nbdim-2):petab_child(nbdim-2), 
     1465      REAL,INTENT(OUT), 
     1466     &        DIMENSION(pttab_child(nbdim-2):petab_child(nbdim-2), 
    13901467     &                pttab_child(nbdim-1):petab_child(nbdim-1), 
    13911468     &                pttab_child(nbdim):petab_child(nbdim)) :: tabout 
    13921469C 
    13931470C     Local variables       
    1394       REAL, DIMENSION(:,:,:), Allocatable :: tabtemp 
     1471      REAL, DIMENSION(pttab_child(nbdim-2):petab_child(nbdim-2), 
     1472     &                 pttab_child(nbdim-1):petab_child(nbdim-1), 
     1473     &                 indmin(nbdim):indmax(nbdim)) :: tabtemp 
    13951474      INTEGER i,j,k 
    1396 C 
    1397 C         
    1398       Allocate(tabtemp(pttab_child(nbdim-2):petab_child(nbdim-2), 
    1399      &                 pttab_child(nbdim-1):petab_child(nbdim-1), 
    1400      &                 indmin(nbdim):indmax(nbdim))) 
     1475      INTEGER :: coeffraf, locind_child_left, kdeb 
     1476C 
    14011477C 
    14021478      do k = indmin(nbdim),indmax(nbdim) 
     
    14131489C         
    14141490      enddo 
     1491       
     1492 
     1493      Call Agrif_Compute_nbdim_interp(s_parent(nbdim),s_child(nbdim), 
     1494     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left) 
     1495            
     1496      IF (coeffraf == 1) THEN 
     1497       
     1498      kdeb = indmin(3)+locind_child_left-2 
     1499      do k=pttab_child(3),petab_child(3) 
     1500      kdeb = kdeb + 1 
     1501      do j = pttab_child(2),petab_child(2) 
     1502        do i = pttab_child(1),petab_child(1) 
     1503        tabout(i,j,k) = tabtemp(i,j,kdeb) 
     1504      enddo 
     1505      enddo 
     1506      enddo 
     1507               
     1508      ELSE       
    14151509C 
    14161510      do j=pttab_child(nbdim-1),petab_child(nbdim-1)  
     
    14241518     &           pttab_child(nbdim),petab_child(nbdim), 
    14251519     &           s_parent(nbdim),s_child(nbdim), 
    1426      &           ds_parent(nbdim),ds_child(nbdim)) 
     1520     &           ds_parent(nbdim),ds_child(nbdim),coeffraf) 
    14271521C 
    14281522        enddo  
    14291523C        
    14301524      enddo 
    1431 C                 
    1432       Deallocate(tabtemp) 
     1525      ENDIF 
    14331526C 
    14341527      Return 
     
    14611554      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child 
    14621555      REAL, DIMENSION(nbdim) :: s_child,s_parent,ds_child,ds_parent 
    1463       REAL, DIMENSION(indmin(nbdim-3):indmax(nbdim-3), 
     1556      REAL,INTENT(IN), DIMENSION(indmin(nbdim-3):indmax(nbdim-3), 
    14641557     &                indmin(nbdim-2):indmax(nbdim-2), 
    14651558     &                indmin(nbdim-1):indmax(nbdim-1), 
    14661559     &                indmin(nbdim):indmax(nbdim)) :: tabin         
    1467       REAL, DIMENSION(pttab_child(nbdim-3):petab_child(nbdim-3), 
     1560      REAL,INTENT(OUT), 
     1561     &       DIMENSION(pttab_child(nbdim-3):petab_child(nbdim-3), 
    14681562     &                pttab_child(nbdim-2):petab_child(nbdim-2), 
    14691563     &                pttab_child(nbdim-1):petab_child(nbdim-1), 
     
    14711565C 
    14721566C     Local variables       
    1473       REAL, DIMENSION(:,:,:,:), Allocatable :: tabtemp 
    1474       INTEGER i,j,k,l 
    1475 C 
    1476 C         
    1477       Allocate(tabtemp(pttab_child(nbdim-3):petab_child(nbdim-3), 
     1567      REAL, DIMENSION(pttab_child(nbdim-3):petab_child(nbdim-3), 
    14781568     &                 pttab_child(nbdim-2):petab_child(nbdim-2), 
    14791569     &                 pttab_child(nbdim-1):petab_child(nbdim-1),   
    1480      &                 indmin(nbdim):indmax(nbdim))) 
     1570     &                 indmin(nbdim):indmax(nbdim)) :: tabtemp 
     1571      INTEGER i,j,k,l 
     1572      INTEGER :: coeffraf 
     1573C 
    14811574C 
    14821575      do l = indmin(nbdim),indmax(nbdim) 
     
    14961589      enddo 
    14971590C 
     1591      coeffraf = nint(ds_parent(nbdim)/ds_child(nbdim)) 
     1592       
    14981593      do k = pttab_child(nbdim-1),petab_child(nbdim-1) 
    14991594C 
     
    15081603     &           pttab_child(nbdim),petab_child(nbdim), 
    15091604     &           s_parent(nbdim),s_child(nbdim), 
    1510      &           ds_parent(nbdim),ds_child(nbdim)) 
     1605     &           ds_parent(nbdim),ds_child(nbdim),coeffraf) 
    15111606C 
    15121607          enddo 
     
    15151610C        
    15161611      enddo 
    1517 C                 
    1518       Deallocate(tabtemp) 
    15191612C 
    15201613      Return 
     
    15471640      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child 
    15481641      REAL, DIMENSION(nbdim) :: s_child,s_parent,ds_child,ds_parent 
    1549       REAL, DIMENSION(indmin(nbdim-4):indmax(nbdim-4), 
     1642      REAL,INTENT(IN), DIMENSION(indmin(nbdim-4):indmax(nbdim-4), 
    15501643     &                indmin(nbdim-3):indmax(nbdim-3), 
    15511644     &                indmin(nbdim-2):indmax(nbdim-2), 
    15521645     &                indmin(nbdim-1):indmax(nbdim-1), 
    15531646     &                indmin(nbdim):indmax(nbdim)) :: tabin   
    1554       REAL, DIMENSION(pttab_child(nbdim-4):petab_child(nbdim-4), 
     1647      REAL,INTENT(OUT), 
     1648     &    DIMENSION(pttab_child(nbdim-4):petab_child(nbdim-4), 
    15551649     &                pttab_child(nbdim-3):petab_child(nbdim-3), 
    15561650     &                pttab_child(nbdim-2):petab_child(nbdim-2), 
     
    15591653C 
    15601654C     Local variables       
    1561       REAL, DIMENSION(:,:,:,:,:), Allocatable :: tabtemp 
    1562       INTEGER i,j,k,l,m 
    1563 C 
    1564 C         
    1565       Allocate(tabtemp(pttab_child(nbdim-4):petab_child(nbdim-4), 
     1655      REAL, DIMENSION(pttab_child(nbdim-4):petab_child(nbdim-4), 
    15661656     &                 pttab_child(nbdim-3):petab_child(nbdim-3), 
    15671657     &                 pttab_child(nbdim-2):petab_child(nbdim-2), 
    15681658     &                 pttab_child(nbdim-1):petab_child(nbdim-1),     
    1569      &                 indmin(nbdim):indmax(nbdim))) 
     1659     &                 indmin(nbdim):indmax(nbdim)) :: tabtemp 
     1660      INTEGER i,j,k,l,m 
     1661      INTEGER :: coeffraf 
     1662C 
    15701663C 
    15711664      do m = indmin(nbdim),indmax(nbdim) 
     
    15861679C         
    15871680      enddo 
     1681       
     1682      coeffraf = nint(ds_parent(nbdim)/ds_child(nbdim)) 
    15881683C 
    15891684      do l = pttab_child(nbdim-1),petab_child(nbdim-1)  
     
    16021697     &             pttab_child(nbdim),petab_child(nbdim), 
    16031698     &             s_parent(nbdim),s_child(nbdim), 
    1604      &             ds_parent(nbdim),ds_child(nbdim)) 
     1699     &             ds_parent(nbdim),ds_child(nbdim),coeffraf) 
    16051700C 
    16061701            enddo 
     
    16111706C        
    16121707      enddo 
    1613 C                 
    1614       Deallocate(tabtemp) 
     1708C 
    16151709C 
    16161710      Return 
     
    16431737      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child 
    16441738      REAL, DIMENSION(nbdim) :: s_child,s_parent,ds_child,ds_parent 
    1645       REAL, DIMENSION(indmin(nbdim-5):indmax(nbdim-5), 
     1739      REAL,INTENT(IN), DIMENSION(indmin(nbdim-5):indmax(nbdim-5), 
    16461740     &                indmin(nbdim-4):indmax(nbdim-4), 
    16471741     &                indmin(nbdim-3):indmax(nbdim-3),  
     
    16491743     &                indmin(nbdim-1):indmax(nbdim-1), 
    16501744     &                indmin(nbdim):indmax(nbdim)) :: tabin         
    1651       REAL, DIMENSION(pttab_child(nbdim-5):petab_child(nbdim-5), 
     1745      REAL,INTENT(OUT), 
     1746     &    DIMENSION(pttab_child(nbdim-5):petab_child(nbdim-5), 
    16521747     &                pttab_child(nbdim-4):petab_child(nbdim-4), 
    16531748     &                pttab_child(nbdim-3):petab_child(nbdim-3), 
     
    16571752C 
    16581753C     Local variables       
    1659       REAL, DIMENSION(:,:,:,:,:,:), Allocatable :: tabtemp 
    1660       INTEGER i,j,k,l,m,n 
    1661 C 
    1662 C         
    1663       Allocate(tabtemp(pttab_child(nbdim-5):petab_child(nbdim-5), 
     1754      REAL, DIMENSION(pttab_child(nbdim-5):petab_child(nbdim-5), 
    16641755     &                 pttab_child(nbdim-4):petab_child(nbdim-4), 
    16651756     &                 pttab_child(nbdim-3):petab_child(nbdim-3), 
    16661757     &                 pttab_child(nbdim-2):petab_child(nbdim-2),     
    16671758     &                 pttab_child(nbdim-1):petab_child(nbdim-1),     
    1668      &                 indmin(nbdim):indmax(nbdim))) 
     1759     &                 indmin(nbdim):indmax(nbdim)) :: tabtemp 
     1760      INTEGER i,j,k,l,m,n 
     1761      INTEGER :: coeffraf 
     1762C 
     1763C         
    16691764C 
    16701765      do n = indmin(nbdim),indmax(nbdim) 
     
    16871782C         
    16881783      enddo 
     1784       
     1785      coeffraf = nint(ds_parent(nbdim)/ds_child(nbdim)) 
    16891786C 
    16901787      do m = pttab_child(nbdim-1),petab_child(nbdim-1)  
     
    17041801     &             pttab_child(nbdim),petab_child(nbdim), 
    17051802     &             s_parent(nbdim),s_child(nbdim), 
    1706      &             ds_parent(nbdim),ds_child(nbdim)) 
     1803     &             ds_parent(nbdim),ds_child(nbdim),coeffraf) 
    17071804C 
    17081805            enddo 
     
    17151812      enddo 
    17161813C                 
    1717       Deallocate(tabtemp) 
    17181814C 
    17191815      Return 
     
    17311827     &                           parenttab,childtab, 
    17321828     &                           indmin,indmax,pttab_child,petab_child, 
    1733      &                           s_parent,s_child,ds_parent,ds_child)    
     1829     &                           s_parent,s_child,ds_parent,ds_child, 
     1830     &                           coeffraf)    
    17341831C 
    17351832CCC   Description: 
     
    17441841      INTEGER :: indmin,indmax 
    17451842      INTEGER :: pttab_child,petab_child 
    1746       REAL,DIMENSION(indmin:indmax)           :: parenttab        
    1747       REAL,DIMENSION(pttab_child:petab_child) :: childtab       
     1843      REAL,INTENT(IN),DIMENSION(indmin:indmax)           :: parenttab        
     1844      REAL,INTENT(OUT),DIMENSION(pttab_child:petab_child) :: childtab         
    17481845      REAL    :: s_parent,s_child,ds_parent,ds_child  
     1846      INTEGER :: coeffraf 
    17491847C  
    17501848C 
     
    17741872     &         indmax-indmin+1,petab_child-pttab_child+1, 
    17751873     &         s_parent,s_child,ds_parent,ds_child) 
    1776 C               
     1874C         
     1875        elseif (TYPEinterp .EQ. AGRIF_WENO) then 
     1876C           
     1877C         Eno interpolation 
     1878          Call weno1D 
     1879     &         (parenttab,childtab, 
     1880     &         indmax-indmin+1,petab_child-pttab_child+1, 
     1881     &         s_parent,s_child,ds_parent,ds_child) 
     1882C             
    17771883        Else if (TYPEinterp .EQ. AGRIF_LINEARCONSERV) then 
    17781884C           
     
    18121918C 
    18131919 
    1814  
    1815 C                         
     1920      Subroutine Agrif_Compute_nbdim_interp(s_parent,s_child, 
     1921     &  ds_parent,ds_child,coeffraf,locind_child_left) 
     1922      real :: s_parent,s_child,ds_parent,ds_child 
     1923      integer :: coeffraf,locind_child_left 
     1924      
     1925      coeffraf = nint(ds_parent/ds_child) 
     1926      locind_child_left = 1 + agrif_int((s_child-s_parent)/ds_parent) 
     1927      End Subroutine Agrif_Compute_nbdim_interp 
     1928C           
     1929 
     1930      Subroutine Agrif_Find_list_interp(list_interp,pttab,petab, 
     1931     &                          pttab_Child,pttab_Parent,nbdim, 
     1932     &                          indmin,indmax,indminglob, 
     1933     &      indmaxglob,indminglob2,indmaxglob2,parentarray, 
     1934     &       pttruetab,cetruetab,member,memberin, 
     1935     &      find_list_interp 
     1936#if defined AGRIF_MPI 
     1937     &     ,tab4t,memberinall 
     1938#endif 
     1939     &    )      
     1940      TYPE(Agrif_List_Interp_Loc), Pointer :: list_interp 
     1941      INTEGER :: nbdim 
     1942      INTEGER,DIMENSION(nbdim)   :: pttab,petab,pttab_Child,pttab_Parent 
     1943      LOGICAL :: find_list_interp 
     1944      Type(Agrif_List_Interp_loc), Pointer :: parcours 
     1945      INTEGER,DIMENSION(nbdim)   :: indmin,indmax   
     1946      INTEGER,DIMENSION(nbdim)   :: indminglob,indmaxglob 
     1947      INTEGER,DIMENSION(nbdim)   :: pttruetab,cetruetab       
     1948      INTEGER,DIMENSION(nbdim)   :: indminglob2,indmaxglob2   
     1949      INTEGER,DIMENSION(nbdim,2,2) :: parentarray 
     1950      LOGICAL :: member, memberin 
     1951      INTEGER :: i 
     1952#ifdef AGRIF_MPI 
     1953C 
     1954      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,4) :: tab4t 
     1955      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: memberinall 
     1956#endif  
     1957                     
     1958      find_list_interp = .FALSE. 
     1959       
     1960      parcours => list_interp 
     1961      Find_loop :   Do While (associated(parcours)) 
     1962        Do i=1,nbdim 
     1963          IF ((pttab(i) /= parcours%interp_loc%pttab(i)).OR. 
     1964     &        (petab(i) /= parcours%interp_loc%petab(i)).OR. 
     1965     &        (pttab_child(i) /= parcours%interp_loc%pttab_child(i)).OR. 
     1966     &        (pttab_parent(i) /= parcours%interp_loc%pttab_parent(i))) 
     1967     &               THEN 
     1968            parcours=>parcours%suiv 
     1969            Cycle Find_loop 
     1970          ENDIF 
     1971        EndDo 
     1972C        print *,'ok trouve' 
     1973        indmin = parcours%interp_loc%indmin(1:nbdim) 
     1974        indmax = parcours%interp_loc%indmax(1:nbdim) 
     1975         
     1976        pttruetab = parcours%interp_loc%pttruetab(1:nbdim) 
     1977        cetruetab = parcours%interp_loc%cetruetab(1:nbdim) 
     1978                 
     1979#if !defined AGRIF_MPI 
     1980        indminglob = parcours%interp_loc%indminglob(1:nbdim) 
     1981        indmaxglob = parcours%interp_loc%indmaxglob(1:nbdim) 
     1982#else 
     1983        indminglob2 = parcours%interp_loc%indminglob2(1:nbdim) 
     1984        indmaxglob2 = parcours%interp_loc%indmaxglob2(1:nbdim) 
     1985        parentarray = parcours%interp_loc%parentarray(1:nbdim,:,:) 
     1986        member = parcours%interp_loc%member 
     1987        tab4t = parcours%interp_loc%tab4t(1:nbdim,0:Agrif_Nbprocs-1,1:4) 
     1988        memberinall = parcours%interp_loc%memberinall(0:Agrif_Nbprocs-1) 
     1989#endif         
     1990        memberin = parcours%interp_loc%memberin 
     1991        find_list_interp = .TRUE.    
     1992        Exit Find_loop 
     1993      End Do Find_loop   
     1994                               
     1995      End Subroutine Agrif_Find_list_interp    
     1996       
     1997      Subroutine Agrif_AddTo_list_interp(list_interp,pttab,petab, 
     1998     &                          pttab_Child,pttab_Parent,indmin,indmax, 
     1999     &                          indminglob,indmaxglob, 
     2000     &                          indminglob2,indmaxglob2, 
     2001     &                          parentarray,pttruetab,cetruetab, 
     2002     &                          member,memberin,nbdim 
     2003#if defined AGRIF_MPI 
     2004     &      ,tab4t,memberinall 
     2005#endif 
     2006     &    ) 
     2007           
     2008      TYPE(Agrif_List_Interp_Loc), Pointer :: list_interp 
     2009      INTEGER :: nbdim 
     2010      INTEGER,DIMENSION(nbdim)   :: pttab,petab,pttab_Child,pttab_Parent 
     2011      INTEGER,DIMENSION(nbdim)   :: indmin,indmax 
     2012      INTEGER,DIMENSION(nbdim)   :: indminglob,indmaxglob 
     2013      INTEGER,DIMENSION(nbdim)   :: indminglob2,indmaxglob2 
     2014      INTEGER,DIMENSION(nbdim)   :: pttruetab,cetruetab 
     2015      INTEGER,DIMENSION(nbdim,2,2) :: parentarray 
     2016      LOGICAL :: member, memberin 
     2017#ifdef AGRIF_MPI 
     2018C 
     2019      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,4) :: tab4t 
     2020      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1) :: memberinall 
     2021#endif                    
     2022      Type(Agrif_List_Interp_loc), Pointer :: parcours 
     2023             
     2024       Allocate(parcours) 
     2025      Allocate(parcours%interp_loc) 
     2026       
     2027      parcours%interp_loc%pttab(1:nbdim) = pttab(1:nbdim) 
     2028      parcours%interp_loc%petab(1:nbdim) = petab(1:nbdim) 
     2029      parcours%interp_loc%pttab_child(1:nbdim) = pttab_child(1:nbdim) 
     2030      parcours%interp_loc%pttab_parent(1:nbdim) = pttab_parent(1:nbdim) 
     2031   
     2032   
     2033      parcours%interp_loc%indmin(1:nbdim) = indmin(1:nbdim) 
     2034      parcours%interp_loc%indmax(1:nbdim) = indmax(1:nbdim) 
     2035 
     2036      parcours%interp_loc%memberin = memberin 
     2037#if !defined AGRIF_MPI 
     2038      parcours%interp_loc%indminglob(1:nbdim) = indminglob(1:nbdim) 
     2039      parcours%interp_loc%indmaxglob(1:nbdim) = indmaxglob(1:nbdim) 
     2040#else 
     2041      parcours%interp_loc%indminglob2(1:nbdim) = indminglob2(1:nbdim) 
     2042      parcours%interp_loc%indmaxglob2(1:nbdim) = indmaxglob2(1:nbdim) 
     2043      parcours%interp_loc%parentarray(1:nbdim,:,:)  
     2044     &       = parentarray(1:nbdim,:,:) 
     2045      parcours%interp_loc%member = member 
     2046      Allocate(parcours%interp_loc%tab4t(nbdim,0:Agrif_Nbprocs-1,4)) 
     2047      Allocate(parcours%interp_loc%memberinall(0:Agrif_Nbprocs-1)) 
     2048      parcours%interp_loc%tab4t=tab4t    
     2049      parcours%interp_loc%memberinall=memberinall    
     2050#endif       
     2051 
     2052      parcours%interp_loc%pttruetab(1:nbdim) = pttruetab(1:nbdim) 
     2053      parcours%interp_loc%cetruetab(1:nbdim) = cetruetab(1:nbdim) 
     2054       
     2055      parcours%suiv => list_interp 
     2056       
     2057      list_interp => parcours 
     2058      End Subroutine Agrif_Addto_list_interp  
     2059                 
    18162060      End Module Agrif_Interpolation 
  • trunk/AGRIF/AGRIF_FILES/modinterpbasic.F

    r447 r662  
    3636      IMPLICIT NONE 
    3737C              
     38      Real,Dimension(Agrif_MaxRaff) :: tabdiff2, tabdiff3 
     39      Real,Dimension(:),Allocatable::tabtest4       
     40        
    3841      CONTAINS 
    3942C     Define procedures contained in this module 
    40 C  
    41 C 
     43 
    4244C     **************************************************************************   
    4345CCC   Subroutine Linear1d   
     
    5961C     Arguments 
    6062      INTEGER             :: np,nc       
    61       REAL, DIMENSION(np) :: x       
    62       REAL, DIMENSION(nc) :: y   
     63      REAL,INTENT(IN), DIMENSION(np) :: x       
     64      REAL,INTENT(OUT), DIMENSION(nc) :: y   
    6365      REAL                :: s_parent,s_child,ds_parent,ds_child 
    6466C 
    6567C     Local scalars 
    6668      INTEGER :: i,coeffraf,locind_parent_left 
    67       REAL    :: ypos,globind_parent_left 
     69      REAL    :: ypos,globind_parent_left,globind_parent_right 
     70      REAL    :: invds, invds2 
     71      REAL :: ypos2,diff 
    6872C 
    6973C 
     
    8185      endif                           
    8286C 
    83       ypos = s_child       
    84 C 
    85       do i = 1,nc-1 
    86 C 
    87         locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent) 
    88 C 
     87      ypos = s_child  
     88 
     89      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent) 
     90 
    8991        globind_parent_left = s_parent  
    9092     &                        + (locind_parent_left - 1)*ds_parent 
    91 C         
    92         y(i) = ((globind_parent_left + ds_parent - ypos) 
    93      &          *x(locind_parent_left) 
    94      &        + (ypos - globind_parent_left) 
    95      &          *x(locind_parent_left+1)) 
    96      &         / ds_parent                 
    97 C 
    98         ypos = ypos + ds_child 
     93 
     94        globind_parent_right = globind_parent_left + ds_parent 
     95 
     96C 
     97      invds = 1./ds_parent 
     98      invds2 = ds_child/ds_parent 
     99       
     100      ypos2 = ypos*invds 
     101      globind_parent_right=globind_parent_right*invds 
     102       
     103      do i = 1,nc-1 
     104C 
     105        if (ypos2 > globind_parent_right) then 
     106           locind_parent_left = locind_parent_left + 1. 
     107           globind_parent_right = globind_parent_right + 1. 
     108        endif 
     109         
     110        diff=(globind_parent_right - ypos2) 
     111         
     112        y(i) = (diff*x(locind_parent_left) 
     113     &        + (1.-diff)*x(locind_parent_left+1)) 
     114C 
     115        ypos2 = ypos2 + invds2 
    99116C 
    100117      enddo 
    101118C 
     119      ypos = s_child + (nc-1)*ds_child 
    102120      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent) 
    103121C 
     
    114132     &            *x(locind_parent_left) 
    115133     &          + (ypos - globind_parent_left) 
    116      &            *x(locind_parent_left+1)) 
    117      &           / ds_parent      
     134     &            *x(locind_parent_left+1))*invds 
    118135C 
    119136      endif                                           
     
    123140C        
    124141      End Subroutine Linear1d    
     142        
    125143C 
    126144C 
     
    145163C     Arguments 
    146164      INTEGER             :: np,nc       
    147       REAL, DIMENSION(np) :: x       
    148       REAL, DIMENSION(nc) :: y   
     165      REAL,INTENT(IN), DIMENSION(np) :: x       
     166      REAL,INTENT(OUT), DIMENSION(nc) :: y   
    149167      REAL                :: s_parent,s_child,ds_parent,ds_child  
    150168C 
     
    153171      REAL    :: ypos,globind_parent_left 
    154172      REAL    :: X1,X2,X3  
     173      real :: deltax,invdsparent 
     174      real t1,t2,t3,t4,t5,t6,t7,t8 
    155175C 
    156176C  
     
    175195C 
    176196      endif 
     197       
     198      invdsparent=1./ds_parent 
    177199C 
    178200      ypos = s_child       
     
    182204        locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent) 
    183205C 
     206 
    184207        globind_parent_left = s_parent  
    185208     &                        + (locind_parent_left - 1)*ds_parent  
    186 C 
    187         if (locind_parent_left+2 <= np) then             
    188 C 
    189             X1 = (x(locind_parent_left+1)-x(locind_parent_left)) 
    190      &           /ds_parent 
    191 C  
    192             X2 = (x(locind_parent_left+2)-x(locind_parent_left+1)) 
    193      &           /ds_parent 
    194 C 
    195             X3 = (X2 - X1)/(2.*ds_parent)                  
    196 C 
    197             y(i) = x(locind_parent_left) +  
    198      &             (ypos - globind_parent_left)*X1 + 
    199      &             (ypos - globind_parent_left)* 
    200      &             (ypos - globind_parent_left - ds_parent)*X3  
    201 C 
    202           elseif (locind_parent_left+1 <= np) then  
    203 C 
    204             X1 = (x(locind_parent_left)-x(locind_parent_left-1)) 
    205      &           /ds_parent 
    206 C      
    207             X2 = (x(locind_parent_left+1)-x(locind_parent_left)) 
    208      &           /ds_parent 
    209 C  
    210             X3 = (X2 - X1)/(2.*ds_parent)                  
    211 C 
    212             y(i) = x(locind_parent_left-1) +  
    213      &             (ypos - globind_parent_left - ds_parent)*X1 + 
    214      &             (ypos - globind_parent_left - ds_parent)* 
    215      &             (ypos - globind_parent_left)*X3 
    216 C 
    217           else 
    218 C 
    219             X1 = (x(locind_parent_left-1)-x(locind_parent_left-2)) 
    220      &           /ds_parent 
    221 C      
    222             X2 = (x(locind_parent_left)-x(locind_parent_left-1)) 
    223      &           /ds_parent 
    224 C  
    225             X3 = (X2 - X1)/(2.*ds_parent)                  
    226 C 
    227             y(i) = x(locind_parent_left-2) +  
    228      &             (ypos - globind_parent_left - 2.*ds_parent)*X1 + 
    229      &             (ypos - globind_parent_left - 2.*ds_parent)* 
    230      &             (ypos - globind_parent_left - ds_parent)*X3 
    231 C 
    232         endif    
    233 C        
    234         ypos = ypos + ds_child  
     209      
     210        deltax = invdsparent*(ypos-globind_parent_left) 
     211        ypos = ypos + ds_child 
     212         if (abs(deltax).LE.0.0001) then 
     213           y(i)=x(locind_parent_left) 
     214            
     215           cycle 
     216         endif 
     217C            
     218C 
     219        t2 = deltax - 2. 
     220        t3 = deltax - 1. 
     221        t4 = deltax + 1. 
     222         
     223        t5 = -(1./6.)*deltax*t2*t3 
     224        t6 = 0.5*t2*t3*t4 
     225        t7 = -0.5*deltax*t2*t4 
     226        t8 = (1./6.)*deltax*t3*t4 
     227         
     228        y(i)=t5*x(locind_parent_left-1)+t6*x(locind_parent_left) 
     229     &  +t7*x(locind_parent_left+1)+t8*x(locind_parent_left+2) 
     230C 
    235231C 
    236232      enddo 
     
    261257C     Arguments 
    262258      INTEGER             :: np,nc       
    263       REAL, DIMENSION(np) :: x       
    264       REAL, DIMENSION(nc) :: y   
     259      REAL,INTENT(IN), DIMENSION(np) :: x       
     260      REAL,INTENT(OUT), DIMENSION(nc) :: y   
    265261      REAL                :: s_parent,s_child,ds_parent,ds_child 
    266262C 
     
    551547C     Arguments 
    552548      Integer             :: np,nc       
    553       Real, Dimension(np) :: x       
    554       Real, Dimension(nc) :: y 
    555       Real, Dimension(:),Allocatable :: ytemp 
     549      Real, INTENT(IN),Dimension(np) :: x       
     550      Real, INTENT(OUT),Dimension(nc) :: y 
     551C      Real, Dimension(:),Allocatable :: ytemp 
    556552      Real                :: s_parent,s_child,ds_parent,ds_child 
    557553C 
     
    561557      Real    :: ypos 
    562558      integer :: i1,jj 
    563       Real :: xpmin,cavg,a,b 
     559      Real :: xpmin,a 
    564560C       
    565561      Real :: xrmin,xrmax,am3,s2,s1   
    566       Real, Dimension(np) :: dela,xr,xl,delta,a6,slope,slope2 
    567       Real, Dimension(:),Allocatable  :: diff,diff2,diff3     
     562      Real, Dimension(np) :: xl,delta,a6,slope 
     563C      Real, Dimension(:),Allocatable  :: diff,diff2,diff3     
    568564      INTEGER :: diffmod 
     565      REAL :: invcoeffraf 
    569566C       
    570567      coeffraf = nint(ds_parent/ds_child) 
     
    575572          return 
    576573      End If 
    577 C       
    578       Allocate(ytemp(-2*coeffraf:nc+2*coeffraf)) 
     574      invcoeffraf = ds_child/ds_parent 
     575C       
     576 
     577      IF( .NOT. allocated(tabtest4) ) THEN     
     578      Allocate(tabtest4(-2*coeffraf:nc+2*coeffraf)) 
     579      ELSE 
     580         IF (size(tabtest4) .LT. nc+4*coeffraf+1)THEN 
     581         deallocate( tabtest4 ) 
     582         Allocate(tabtest4(-2*coeffraf:nc+2*coeffraf)) 
     583         ENDIF 
     584      ENDIF   
    579585      ypos = s_child   
    580586C 
     
    587593      i1 = 1+agrif_int((xpmin-s_child)/ds_child)         
    588594C      
    589       Allocate( diff(coeffraf),diff2(coeffraf),diff3(coeffraf) ) 
    590 C       
    591          diff(:) = ds_child/ds_parent 
    592 C       
     595C 
     596       
    593597      Do i=1,coeffraf 
    594          a = real(i-1)*ds_child/ds_parent 
    595          b = real(i)*ds_child/ds_parent 
    596          diff2(i) = 0.5*(b*b - a*a)   
    597          diff3(i) = (1./3.)*(b*b*b - a*a*a) 
    598       End do 
     598        tabdiff2(i)=(real(i)-0.5)*invcoeffraf 
     599      EndDo 
     600 
     601      a = invcoeffraf**2  
     602      tabdiff3(1) = (1./3.)*a 
     603      a=2.*a 
     604      Do i=2,coeffraf 
     605        tabdiff3(i) = tabdiff3(i-1)+(real(i)-1)*a 
     606      EndDo 
    599607C 
    600608      if( locind_parent_last+2 <= np ) then 
     
    612620      endif     
    613621C  
     622C 
    614623      Do i = nmin,nmax 
    615624         slope(i) = x(i) - x(i-1) 
    616          slope2(i) = 2.*abs(slope(i)) 
    617625      Enddo 
    618 C 
    619       Do i = nmin,nmax-1 
    620          dela(i) = 0.5 * ( slope(i) + slope(i+1) ) 
    621 C Van Leer slope limiter 
    622          dela(i) = min( abs(dela(i)),slope2(i), 
    623      &                  slope2(i+1) )*sign(1.,dela(i)) 
    624          IF( slope(i)*slope(i+1) <= 0. ) dela(i) = 0. 
     626 
     627      Do i = nmin+1,nmax-1 
     628         xl(i)= 0.5*(x(i-1)+x(i)) 
     629     &      -0.08333333333333*(slope(i+1)-slope(i-1))  
    625630      Enddo 
    626631C 
    627       Do i = nmin,nmax-2 
    628          xr(i) = x(i) + (1./2.)*slope(i+1) + (-1./6.)*dela(i+1) 
    629      &                                     + ( 1./6. )*dela(i) 
    630       Enddo 
    631 C 
    632       Do i = nmin,nmax-2 
    633          xrmin = min(x(i),x(i+1)) 
    634          xrmax = max(x(i),x(i+1)) 
    635          xr(i) = min(xr(i),xrmax) 
    636          xr(i) = max(xr(i),xrmin) 
    637          xl(i+1) = xr(i)          
    638       Enddo 
    639632C apply parabolic monotonicity 
    640633       Do i = locind_parent_left,locind_parent_last 
    641           If( ( (xr(i)-x(i))* (x(i)-xl(i)) ) .le. 0. ) then 
    642              xl(i) = x(i)  
    643              xr(i) = x(i) 
    644           Endif           
    645           delta(i) = xr(i) - xl(i) 
    646           am3 = 3. * x(i) 
    647           s1  = am3 - 2. * xr(i) 
    648           s2  = am3 - 2. * xl(i) 
    649           IF( delta(i) * (xl(i) - s1) .le. 0. ) xl(i) = s1 
    650           IF( delta(i) * (s2 - xr(i)) .le. 0. ) xr(i) = s2 
    651           delta(i) = xr(i) - xl(i) 
    652           a6(i) = 6.*x(i)-3.*(xl(i) +xr(i)) 
     634          delta(i) = xl(i+1) - xl(i) 
     635          a6(i) = 6.*x(i)-3.*(xl(i) +xl(i+1)) 
    653636C 
    654637       End do    
    655638C 
    656639        diffmod = 0 
    657         IF (mod(coeffraf,2) == 0) diffmod = 1            
     640       IF (mod(coeffraf,2) == 0) diffmod = 1 
    658641C 
    659642        ipos = i1 
     
    661644        Do iparent = locind_parent_left,locind_parent_last        
    662645             pos=1 
    663              cavg = 0. 
    664646             Do jj = ipos - coeffraf/2+diffmod,ipos + coeffraf/2 
    665647C 
    666                ytemp(jj) = (diff(pos)*xl(iparent)    
    667      &             + diff2(pos) 
    668      &             *  (delta(iparent)+a6(iparent)) 
    669      &             - diff3(pos)*a6(iparent))*coeffraf 
    670                                
    671                cavg = cavg + ytemp(jj) 
     648               tabtest4(jj) = xl(iparent)    
     649     &             + tabdiff2(pos) *  (delta(iparent)+a6(iparent)) 
     650     &             - tabdiff3(pos) *  a6(iparent) 
    672651               pos = pos+1  
    673652             End do  
     
    677656C 
    678657C 
     658        y(1:nc)=tabtest4(1:nc) 
     659         
     660      Return 
     661      End Subroutine ppm1d 
     662       
     663C     **************************************************************************   
     664CCC   Subroutine weno1d 
     665C     **************************************************************************  
     666C  
     667      Subroutine weno1dnew(x,y,np,nc, 
     668     &                    s_parent,s_child,ds_parent,ds_child)  
     669C 
     670CCC   Description: 
     671CCC   Subroutine to do a 1D interpolation and apply monotonicity constraints 
     672CCC   using piecewise parabolic method   
     673CCC   on a child grid (vector y) from its parent grid (vector x). 
     674CC    Method: 
     675C 
     676C     Declarations: 
     677C 
     678      Implicit none 
     679C         
     680C     Arguments 
     681      Integer             :: np,nc 
     682      Real, Dimension(np) :: x 
     683      Real, Dimension(nc) :: y 
     684      Real, Dimension(:),Allocatable :: ytemp 
     685      Real                :: s_parent,s_child,ds_parent,ds_child 
     686C 
     687C     Local scalars 
     688      Integer :: i,coeffraf,locind_parent_left,locind_parent_last 
     689      Integer :: iparent,ipos,pos,nmin,nmax 
     690      Real    :: ypos 
     691      integer :: i1,jj 
     692      Real :: xpmin,cavg,a,b 
     693C       
     694      Real :: xrmin,xrmax,am3,s2,s1 
     695      Real, Dimension(np) :: xr,xl,delta,a6,slope,slope2,smooth 
     696      Real, Dimension(:),Allocatable  :: diff,diff2,diff3 
     697      INTEGER :: diffmod 
     698      REAL :: invcoeffraf 
     699      integer :: s,l,k 
     700      integer :: etan, etap 
     701      real :: delta0, delta1, delta2 
     702      real :: epsilon 
     703      parameter (epsilon = 1.D-8) 
     704      real, dimension(:,:), allocatable :: ak, ck 
     705C       
     706      coeffraf = nint(ds_parent/ds_child) 
     707C 
     708      If (coeffraf == 1) Then 
     709          locind_parent_left = 1 + nint((s_child - s_parent)/ds_parent) 
     710          y(1:nc) = x(locind_parent_left:locind_parent_left+nc-1) 
     711          return 
     712      End If 
     713      invcoeffraf = ds_child/ds_parent 
     714      Allocate(ak(0:1,coeffraf)) 
     715      Allocate(ck(0:1,coeffraf)) 
     716             
     717C       
     718      Allocate(ytemp(-2*coeffraf:nc+2*coeffraf)) 
     719      ypos = s_child 
     720C 
     721      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent) 
     722      locind_parent_last = 1 + 
     723     &      agrif_ceiling((ypos +(nc - 1) 
     724     &      *ds_child - s_parent)/ds_parent) 
     725C 
     726      xpmin = s_parent + (locind_parent_left-1)*ds_parent 
     727      i1 = 1+agrif_int((xpmin-s_child)/ds_child) 
     728C      
     729      Allocate( diff(coeffraf),diff2(coeffraf),diff3(coeffraf) ) 
     730C       
     731      diff(1)=0.5*invcoeffraf 
     732      do i=2,coeffraf 
     733         diff(i) = diff(i-1)+invcoeffraf 
     734      enddo 
     735       
     736      ak = 0. 
     737      ck = 0. 
     738       
     739      do i=1,coeffraf 
     740         do k=0,1 
     741         do s=0,2 
     742         do l=0,2 
     743           if (l /= s) then 
     744            ak(k,i) = ak(k,i)+(diff(i)-(k-l+1.)) 
     745           endif 
     746         enddo 
     747         enddo 
     748         enddo 
     749                
     750         etap = 0 
     751         etan = 0 
     752         do k=0,1 
     753          if (ak(k,i) > 0) then 
     754            etap = etap+1 
     755          else if (ak(k,i) < 0) then 
     756            etan = etan + 1 
     757          endif 
     758         enddo 
     759                
     760         do k=0,1 
     761           if (ak(k,i) == 0) then 
     762            Ck(k,i) = 1. 
     763           else if (ak(k,i) > 0) then 
     764            Ck(k,i) = 1./(etap * ak(k,i)) 
     765           else 
     766            Ck(k,i) = -1./(etan * ak(k,i)) 
     767           endif 
     768         enddo 
     769      enddo 
     770                      
     771C       
     772      a = 0. 
     773      b = invcoeffraf 
     774      Do i=1,coeffraf 
     775         diff2(i) = 0.5*(b*b - a*a)   
     776         diff3(i) = (1./3.)*(b*b*b - a*a*a) 
     777         a = a + invcoeffraf 
     778         b = b + invcoeffraf 
     779      End do 
     780C 
     781      if( locind_parent_last+2 <= np ) then 
     782           nmax = locind_parent_last+2     
     783      elseif( locind_parent_last+1 <= np ) then 
     784           nmax = locind_parent_last+1 
     785      else 
     786           nmax = locind_parent_last  
     787      endif      
     788C       
     789      if(locind_parent_left-2 >= 1) then 
     790          nmin = locind_parent_left-2 
     791      elseif(locind_parent_left-1 >= 1) then 
     792          nmin = locind_parent_left-1 
     793      else  
     794          nmin = locind_parent_left 
     795      endif     
     796C  
     797      Do i = nmin+1,nmax 
     798         slope(i) = (x(i) - x(i-1)) 
     799      Enddo  
     800      DO i=nmin+2,nmax 
     801        smooth(i) = 0.5*(slope(i)**2+slope(i-1)**2) 
     802     &       +(slope(i)-slope(i-1))**2 
     803      enddo 
     804C 
     805        diffmod = 0 
     806        IF (mod(coeffraf,2) == 0) diffmod = 1            
     807C 
     808        ipos = i1 
     809C                
     810        Do iparent = locind_parent_left,locind_parent_last        
     811             pos=1 
     812              
     813            delta0=1./(epsilon+smooth(iparent  ))**3 
     814            delta1=1./(epsilon+smooth(iparent+1))**3 
     815            delta2=1./(epsilon+smooth(iparent+2))**3    
     816                       
     817             Do jj = ipos - coeffraf/2+diffmod,ipos + coeffraf/2 
     818C 
     819               pos = pos+1  
     820             End do  
     821             ipos = ipos + coeffraf 
     822C 
     823        End do      
     824C 
     825C 
    679826        y(1:nc)=ytemp(1:nc)                                  
    680827        deallocate(ytemp)                 
    681828        deallocate(diff, diff2, diff3) 
     829         
     830        deallocate(ak,ck) 
     831         
    682832      Return 
    683       End Subroutine ppm1d 
     833      End Subroutine weno1dnew 
     834       
     835C     **************************************************************************   
     836CCC   Subroutine weno1d 
     837C     **************************************************************************  
     838C  
     839      Subroutine weno1d(x,y,np,nc, 
     840     &                    s_parent,s_child,ds_parent,ds_child)  
     841C 
     842CCC   Description: 
     843CCC   Subroutine to do a 1D interpolation and apply monotonicity constraints 
     844CCC   using piecewise parabolic method   
     845CCC   on a child grid (vector y) from its parent grid (vector x). 
     846CC    Method: 
     847C 
     848C     Declarations: 
     849C 
     850      Implicit none 
     851C         
     852C     Arguments 
     853      Integer             :: np,nc 
     854      Real, Dimension(np) :: x 
     855      Real, Dimension(nc) :: y 
     856      Real, Dimension(:),Allocatable :: ytemp 
     857      Real                :: s_parent,s_child,ds_parent,ds_child 
     858C 
     859C     Local scalars 
     860      Integer :: i,coeffraf,locind_parent_left,locind_parent_last 
     861      Integer :: iparent,ipos,pos,nmin,nmax 
     862      Real    :: ypos 
     863      integer :: i1,jj 
     864      Real :: xpmin,cavg,a,b 
     865C       
     866      Real :: xrmin,xrmax,am3,s2,s1 
     867      Real, Dimension(np) :: xr,xl,delta,a6,slope,slope2 
     868      Real, Dimension(:),Allocatable  :: diff,diff2,diff3 
     869      INTEGER :: diffmod 
     870      REAL :: invcoeffraf 
     871      integer :: s,l,k 
     872      integer :: etan, etap 
     873      real :: delta0, delta1,sumdelta 
     874      real :: epsilon 
     875      parameter (epsilon = 1.D-8) 
     876C       
     877      coeffraf = nint(ds_parent/ds_child) 
     878C 
     879      If (coeffraf == 1) Then 
     880          locind_parent_left = 1 + nint((s_child - s_parent)/ds_parent) 
     881          y(1:nc) = x(locind_parent_left:locind_parent_left+nc-1) 
     882          return 
     883      End If 
     884      invcoeffraf = ds_child/ds_parent 
     885             
     886C       
     887      Allocate(ytemp(-2*coeffraf:nc+2*coeffraf)) 
     888      ypos = s_child 
     889C 
     890      locind_parent_left = 1 + agrif_int((ypos - s_parent)/ds_parent) 
     891      locind_parent_last = 1 + 
     892     &      agrif_ceiling((ypos +(nc - 1) 
     893     &      *ds_child - s_parent)/ds_parent) 
     894C 
     895      xpmin = s_parent + (locind_parent_left-1)*ds_parent 
     896      i1 = 1+agrif_int((xpmin-s_child)/ds_child) 
     897C      
     898      Allocate( diff(coeffraf)) 
     899C       
     900      diff(1)=0.5*invcoeffraf 
     901      do i=2,coeffraf 
     902         diff(i) = diff(i-1)+invcoeffraf 
     903      enddo 
     904C 
     905      if( locind_parent_last+2 <= np ) then 
     906           nmax = locind_parent_last+2    
     907      else if( locind_parent_last+1 <= np ) then 
     908           nmax = locind_parent_last+1 
     909      else 
     910           nmax = locind_parent_last  
     911      endif      
     912C       
     913      if(locind_parent_left-1 >= 1) then 
     914          nmin = locind_parent_left-1 
     915      else  
     916          nmin = locind_parent_left 
     917      endif     
     918C  
     919      Do i = nmin+1,nmax 
     920         slope(i) = (x(i) - x(i-1)) 
     921      Enddo  
     922C 
     923        diffmod = 0 
     924        IF (mod(coeffraf,2) == 0) diffmod = 1            
     925C 
     926        ipos = i1 
     927C                
     928        Do iparent = locind_parent_left,locind_parent_last        
     929             pos=1 
     930            delta0=1./(epsilon+slope(iparent  )**2)**2 
     931            delta1=1./(epsilon+slope(iparent+1)**2)**2 
     932            sumdelta = 1./(delta0+delta1)              
     933             Do jj = ipos - coeffraf/2+diffmod,ipos + coeffraf/2 
     934C                               
     935          ytemp(jj) = x(iparent)+(diff(pos)-0.5)*( 
     936     &                delta0*slope(iparent)+ 
     937     &                delta1*slope(iparent+1))*sumdelta 
     938               pos = pos+1  
     939             End do  
     940             ipos = ipos + coeffraf 
     941C 
     942        End do      
     943C 
     944C 
     945        y(1:nc)=ytemp(1:nc)                                  
     946        deallocate(ytemp)                 
     947        deallocate(diff) 
     948         
     949      Return 
     950      End Subroutine weno1d 
     951                  
    684952C                               
    685953C     **************************************************************************   
  • trunk/AGRIF/AGRIF_FILES/modlinktomodel.F

    r396 r662  
    1919C 
    2020C 
    21 C 
    2221      Module Agrif_link 
    2322C 
     
    3130c        external Agrif_detect 
    3231C 
    33       IMPLICIT NONE         
    3432        external Agrif_probdim_modtype_def 
    3533        external Agrif_clustering_def 
     
    4038         TYPE(Agrif_Grid), Pointer :: Agrif_Gr   ! Pointer on the current grid   
    4139         End Subroutine Agrif_Set_numberofcells 
    42          
     40      End interface 
     41      Interface 
    4342         Subroutine Agrif_Get_numberofcells(Agrif_Gr) 
    4443         Use Agrif_Types, Only : Agrif_grid 
    4544         TYPE(Agrif_Grid), Pointer :: Agrif_Gr   ! Pointer on the current grid   
    4645         End Subroutine Agrif_Get_numberofcells 
    47           
     46      End interface 
     47      Interface 
    4848         Subroutine Agrif_Allocationcalls(Agrif_Gr) 
    4949         Use Agrif_Types, Only : Agrif_grid 
     
    5151         End Subroutine Agrif_Allocationcalls 
    5252      End interface 
    53     
     53C    
    5454      End Module Agrif_link 
    5555C     ************************************************************************** 
  • trunk/AGRIF/AGRIF_FILES/modmask.F

    r396 r662  
    202202C     Local scalar 
    203203      INTEGER                  :: i,ii,iii,jj,kk,ll,mm,nn  
    204       INTEGER,DIMENSION(nbdim) :: imin,imax 
     204      INTEGER,DIMENSION(nbdim) :: imin,imax,idecal 
    205205      INTEGER                  :: Nbvals 
    206206      REAL                     :: Res 
     
    235235                  imin(iii) = max(indic(iii) - i,ppbtab(iii)) 
    236236                  imax(iii) = min(indic(iii) + i,ppetab(iii)) 
     237                  if (firsttest) then                
     238                  if (indic(iii).GT.ppbtab(iii)) then 
     239 
     240                     idecal = indic 
     241                     idecal(iii) = idecal(iii)-1 
     242                     SELECT CASE(nbdim) 
     243                     CASE (1) 
     244                        if (tempP%var%array1(idecal(1) 
     245     &                            ) == Agrif_SpecialValue) then 
     246                           imin(iii) = imax(iii) 
     247                        endif                      
     248                     CASE (2) 
     249                        if (tempP%var%array2(idecal(1), 
     250     &            idecal(2)) == Agrif_SpecialValue) then 
     251                           imin(iii) = imax(iii) 
     252                        endif 
     253                     CASE (3) 
     254                        if (tempP%var%array3(idecal(1), 
     255     &            idecal(2),idecal(3))  
     256     &                               == Agrif_SpecialValue) then 
     257                           imin(iii) = imax(iii) 
     258                        endif   
     259                     CASE (4) 
     260                        if (tempP%var%array4(idecal(1), 
     261     &            idecal(2),idecal(3),idecal(4))  
     262     &                               == Agrif_SpecialValue) then 
     263                           imin(iii) = imax(iii) 
     264                        endif      
     265                     CASE (5) 
     266                        if (tempP%var%array5(idecal(1), 
     267     &            idecal(2),idecal(3),idecal(4),idecal(5))  
     268     &                               == Agrif_SpecialValue) then 
     269                           imin(iii) = imax(iii) 
     270                        endif   
     271                     CASE (6) 
     272                        if (tempP%var%array6(idecal(1), 
     273     &            idecal(2),idecal(3),idecal(4),idecal(5),idecal(6))  
     274     &                               == Agrif_SpecialValue) then 
     275                           imin(iii) = imax(iii) 
     276                        endif                                                                                            
     277                     END SELECT 
     278                  endif 
     279                  endif 
    237280               endif             
    238281            enddo 
     
    241284            Nbvals = 0 
    242285C 
    243             if ( nbdim .EQ. 1 ) then 
     286            SELECT CASE(nbdim) 
     287            CASE (1) 
    244288               do ii = imin(1),imax(1) 
    245289                    ValParent = parent%var%array1(ii) 
     
    249293                    endif  
    250294               enddo 
    251             endif 
    252 C 
    253             if ( nbdim .EQ. 2 ) then 
     295C 
     296            CASE (2) 
    254297               do jj = imin(2),imax(2) 
    255298               do ii = imin(1),imax(1) 
     
    261304               enddo   
    262305               enddo 
    263             endif 
    264 C 
    265             if ( nbdim .EQ. 3 ) then 
     306                
     307            CASE (3) 
    266308               do kk = imin(3),imax(3) 
    267309               do jj = imin(2),imax(2) 
     
    275317                  enddo   
    276318               enddo 
    277             endif 
    278 C 
    279             if ( nbdim .EQ. 4 ) then 
     319 
     320            CASE (4) 
    280321               do ll = imin(4),imax(4) 
    281322               do kk = imin(3),imax(3) 
     
    291332                  enddo   
    292333               enddo 
    293             endif 
    294 C 
    295             if ( nbdim .EQ. 5 ) then 
     334 
     335            CASE (5) 
    296336               do mm = imin(5),imax(5) 
    297337               do ll = imin(4),imax(4) 
     
    309349                  enddo   
    310350               enddo 
    311             endif 
    312 C 
    313             if ( nbdim .EQ. 6 ) then 
     351 
     352            CASE (6) 
    314353               do nn = imin(6),imax(6) 
    315354               do mm = imin(5),imax(5) 
     
    329368                  enddo   
    330369               enddo 
    331             endif 
     370 
     371            END SELECT 
    332372C 
    333373C 
     
    336376              if (firsttest) then 
    337377                   firsttest = .FALSE. 
     378                   i=1 
    338379                   cycle 
    339380              endif 
    340               if ( nbdim .EQ. 1 ) tempP%var%array1(indic(1))  
     381            SELECT CASE(nbdim) 
     382            CASE (1)               
     383              tempP%var%array1(indic(1))  
    341384     &           = Res/Nbvals 
    342               if ( nbdim .EQ. 2 ) tempP%var%array2(indic(1), 
     385            CASE (2) 
     386              tempP%var%array2(indic(1), 
    343387     &                            indic(2)) = Res/Nbvals 
    344               if ( nbdim .EQ. 3 ) tempP%var%array3(indic(1), 
     388            CASE (3) 
     389              tempP%var%array3(indic(1), 
    345390     &                            indic(2),indic(3)) = Res/Nbvals 
    346               if ( nbdim .EQ. 4 ) tempP%var%array4(indic(1), 
     391            CASE (4) 
     392              tempP%var%array4(indic(1), 
    347393     &                            indic(2),indic(3),indic(4)) 
    348394     &                = Res/Nbvals 
    349               if ( nbdim .EQ. 5 ) tempP%var%array5(indic(1), 
     395            CASE (5) 
     396              tempP%var%array5(indic(1), 
    350397     &                            indic(2),indic(3),indic(4), 
    351398     &                   indic(5)) = Res/Nbvals 
    352               if ( nbdim .EQ. 6 ) tempP%var%array6(indic(1), 
     399            CASE (6) 
     400              tempP%var%array6(indic(1), 
    353401     &                            indic(2),indic(3),indic(4), 
    354402     &                           indic(5),indic(6)) = Res/Nbvals 
     403            END SELECT 
    355404              exit 
    356405            else 
  • trunk/AGRIF/AGRIF_FILES/modmpp.F

    r396 r662  
    3434      Subroutine Get_External_Data(tempC,tempCextend,pttruetab, 
    3535     &   cetruetab,pttruetabwhole,cetruetabwhole,nbdim,memberin, 
    36      &   memberout) 
     36     &   memberout,memberoutall1) 
    3737 
    3838      IMPLICIT NONE 
     
    5454     &                                                 cetruetab2 
    5555      LOGICAL :: memberout1(1),memberoutall(0:Agrif_Nbprocs-1) 
     56      LOGICAL, OPTIONAL :: memberoutall1(0:Agrif_Nbprocs-1) 
    5657      INTEGER :: code 
    5758 
     
    6061 
    6162         
     63        IF (present(memberoutall1)) THEN 
     64        memberoutall = memberoutall1 
     65        ELSE 
    6266         memberout1(1) = memberout 
    6367 
    6468         CALL MPI_ALLGATHER(memberout1,1,MPI_LOGICAL,memberoutall, 
    6569     &                  1,MPI_LOGICAL,MPI_COMM_WORLD,code) 
    66  
     70        ENDIF 
    6771         pttruetab2(:,Agrif_Procrank) = pttruetab(:,Agrif_Procrank) 
    6872         cetruetab2(:,Agrif_Procrank) = cetruetab(:,Agrif_Procrank) 
     
    198202      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1)       :: recvfromproc 
    199203      LOGICAL                                    :: res 
    200       TYPE(AGRIF_PVARIABLE)                      :: temprecv 
     204      TYPE(AGRIF_PVARIABLE), SAVE                      :: temprecv 
    201205 
    202206#include "mpif.h" 
     
    243247     &                        MPI_COMM_WORLD,code) 
    244248                CASE(3) 
    245                    Call MPI_SEND(tempC%var%array3( 
    246      &                        imin(1,k):imax(1,k), 
    247      &                        imin(2,k):imax(2,k), 
    248      &                        imin(3,k):imax(3,k)), 
    249      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
    250      &                        MPI_COMM_WORLD,code) 
     249                  Call Agrif_Send_3Darray(tempC%var%array3, 
     250     &             lbound(tempC%var%array3),imin(:,k),imax(:,k),k) 
    251251                CASE(4) 
    252252                   Call MPI_SEND(tempC%var%array4( 
     
    311311                enddo 
    312312 
    313                allocate(temprecv%var) 
     313             IF (.Not.Associated(temprecv%var)) allocate(temprecv%var) 
    314314             call Agrif_nbdim_allocation(temprecv%var,imin_recv(:,k), 
    315315     &   imax_recv(:,k),nbdim) 
     
    341341     &               MPI_COMM_WORLD,statut,code) 
    342342       END SELECT 
     343            endif 
    343344             
     345            Call MPI_SEND(sendtoproc(k),1,MPI_LOGICAL,k,etiquette, 
     346     &                    MPI_COMM_WORLD,code) 
     347C 
     348            if (sendtoproc(k)) then 
     349C 
     350                iminmax_temp(:,1,k) = imin(:,k) 
     351                iminmax_temp(:,2,k) = imax(:,k) 
     352 
     353                Call MPI_SEND(iminmax_temp(:,:,k), 
     354     &                        2*nbdim,MPI_INTEGER,k,etiquette, 
     355     &                        MPI_COMM_WORLD,code) 
     356C 
     357                SELECT CASE(nbdim) 
     358                CASE(1) 
     359                datasize=SIZE(tempC%var%array1( 
     360     &                        imin(1,k):imax(1,k))) 
     361                   Call MPI_SEND(tempC%var%array1( 
     362     &                        imin(1,k):imax(1,k)), 
     363     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
     364     &                        MPI_COMM_WORLD,code) 
     365                CASE(2) 
     366                datasize=SIZE(tempC%var%array2( 
     367     &                        imin(1,k):imax(1,k), 
     368     &                        imin(2,k):imax(2,k))) 
     369                   Call MPI_SEND(tempC%var%array2( 
     370     &                        imin(1,k):imax(1,k), 
     371     &                        imin(2,k):imax(2,k)), 
     372     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
     373     &                        MPI_COMM_WORLD,code) 
     374                CASE(3) 
     375                datasize=SIZE(tempC%var%array3( 
     376     &                        imin(1,k):imax(1,k), 
     377     &                        imin(2,k):imax(2,k), 
     378     &                        imin(3,k):imax(3,k))) 
     379                   Call MPI_SEND(tempC%var%array3( 
     380     &                        imin(1,k):imax(1,k), 
     381     &                        imin(2,k):imax(2,k), 
     382     &                        imin(3,k):imax(3,k)), 
     383     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
     384     &                        MPI_COMM_WORLD,code) 
     385                CASE(4) 
     386                datasize=SIZE(tempC%var%array4( 
     387     &                        imin(1,k):imax(1,k), 
     388     &                        imin(2,k):imax(2,k), 
     389     &                        imin(3,k):imax(3,k), 
     390     &                        imin(4,k):imax(4,k))) 
     391                   Call MPI_SEND(tempC%var%array4( 
     392     &                        imin(1,k):imax(1,k), 
     393     &                        imin(2,k):imax(2,k), 
     394     &                        imin(3,k):imax(3,k), 
     395     &                        imin(4,k):imax(4,k)), 
     396     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
     397     &                        MPI_COMM_WORLD,code) 
     398                CASE(5) 
     399                datasize=SIZE(tempC%var%array5( 
     400     &                        imin(1,k):imax(1,k), 
     401     &                        imin(2,k):imax(2,k), 
     402     &                        imin(3,k):imax(3,k), 
     403     &                        imin(4,k):imax(4,k), 
     404     &                        imin(5,k):imax(5,k))) 
     405                   Call MPI_SEND(tempC%var%array5( 
     406     &                        imin(1,k):imax(1,k), 
     407     &                        imin(2,k):imax(2,k), 
     408     &                        imin(3,k):imax(3,k), 
     409     &                        imin(4,k):imax(4,k), 
     410     &                        imin(5,k):imax(5,k)), 
     411     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
     412     &                        MPI_COMM_WORLD,code) 
     413                CASE(6) 
     414                datasize=SIZE(tempC%var%array6( 
     415     &                        imin(1,k):imax(1,k), 
     416     &                        imin(2,k):imax(2,k), 
     417     &                        imin(3,k):imax(3,k), 
     418     &                        imin(4,k):imax(4,k), 
     419     &                        imin(5,k):imax(5,k), 
     420     &                        imin(6,k):imax(6,k))) 
     421                   Call MPI_SEND(tempC%var%array6( 
     422     &                        imin(1,k):imax(1,k), 
     423     &                        imin(2,k):imax(2,k), 
     424     &                        imin(3,k):imax(3,k), 
     425     &                        imin(4,k):imax(4,k), 
     426     &                        imin(5,k):imax(5,k), 
     427     &                        imin(6,k):imax(6,k)), 
     428     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
     429     &                        MPI_COMM_WORLD,code) 
     430                END SELECT 
     431C 
     432            endif             
     433             
     434            if (recvfromproc(k)) then 
     435                         
    344436            Call where_valtabtotab_mpi(tempCextend%var, 
    345437     &             temprecv%var,imin_recv(:,k),imax_recv(:,k),0.,nbdim) 
    346438      
    347439                Call Agrif_nbdim_deallocation(temprecv%var,nbdim) 
    348                 deallocate(temprecv%var) 
    349  
    350             endif 
    351  
    352 C 
    353       enddo 
    354  
    355  
    356       do k = Agrif_ProcRank+1,Agrif_Nbprocs-1 
    357 C 
    358 C 
    359             Call MPI_SEND(sendtoproc(k),1,MPI_LOGICAL,k,etiquette, 
    360      &                    MPI_COMM_WORLD,code) 
    361 C 
    362             if (sendtoproc(k)) then 
    363 C 
    364                 iminmax_temp(:,1,k) = imin(:,k) 
    365                 iminmax_temp(:,2,k) = imax(:,k) 
    366  
    367                 Call MPI_SEND(iminmax_temp(:,:,k), 
    368      &                        2*nbdim,MPI_INTEGER,k,etiquette, 
    369      &                        MPI_COMM_WORLD,code) 
    370 C 
    371                 datasize = 1 
    372 C 
    373                 do i = 1,nbdim 
    374 C 
    375                   datasize = datasize * (imax(i,k)-imin(i,k)+1) 
    376 C 
    377                 enddo 
    378 C 
    379                 SELECT CASE(nbdim) 
    380                 CASE(1) 
    381                    Call MPI_SEND(tempC%var%array1( 
    382      &                        imin(1,k):imax(1,k)), 
    383      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
    384      &                        MPI_COMM_WORLD,code) 
    385                 CASE(2) 
    386                    Call MPI_SEND(tempC%var%array2( 
    387      &                        imin(1,k):imax(1,k), 
    388      &                        imin(2,k):imax(2,k)), 
    389      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
    390      &                        MPI_COMM_WORLD,code) 
    391                 CASE(3) 
    392                    Call MPI_SEND(tempC%var%array3( 
    393      &                        imin(1,k):imax(1,k), 
    394      &                        imin(2,k):imax(2,k), 
    395      &                        imin(3,k):imax(3,k)), 
    396      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
    397      &                        MPI_COMM_WORLD,code) 
    398                 CASE(4) 
    399                    Call MPI_SEND(tempC%var%array4( 
    400      &                        imin(1,k):imax(1,k), 
    401      &                        imin(2,k):imax(2,k), 
    402      &                        imin(3,k):imax(3,k), 
    403      &                        imin(4,k):imax(4,k)), 
    404      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
    405      &                        MPI_COMM_WORLD,code) 
    406                 CASE(5) 
    407                    Call MPI_SEND(tempC%var%array5( 
    408      &                        imin(1,k):imax(1,k), 
    409      &                        imin(2,k):imax(2,k), 
    410      &                        imin(3,k):imax(3,k), 
    411      &                        imin(4,k):imax(4,k), 
    412      &                        imin(5,k):imax(5,k)), 
    413      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
    414      &                        MPI_COMM_WORLD,code) 
    415                 CASE(6) 
    416                    Call MPI_SEND(tempC%var%array6( 
    417      &                        imin(1,k):imax(1,k), 
    418      &                        imin(2,k):imax(2,k), 
    419      &                        imin(3,k):imax(3,k), 
    420      &                        imin(4,k):imax(4,k), 
    421      &                        imin(5,k):imax(5,k), 
    422      &                        imin(6,k):imax(6,k)), 
    423      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
    424      &                        MPI_COMM_WORLD,code) 
    425                 END SELECT 
    426 C 
     440C                deallocate(temprecv%var) 
     441 
    427442            endif 
    428443 
     
    448463     &                        MPI_COMM_WORLD,statut,code) 
    449464 
    450                 imin_recv(:,k) = iminmax_temp(:,1,k) 
    451                 imax_recv(:,k) = iminmax_temp(:,2,k) 
    452  
    453                 datasize = 1 
    454 C 
    455                 do i = 1,nbdim 
    456 C 
    457                 datasize = datasize * (imax_recv(i,k)-imin_recv(i,k)+1) 
    458 C 
    459                 enddo 
    460                allocate(temprecv%var) 
    461              call Agrif_nbdim_allocation(temprecv%var,imin_recv(:,k), 
    462      &   imax_recv(:,k),nbdim) 
     465C                imin_recv(:,k) = iminmax_temp(:,1,k) 
     466C                imax_recv(:,k) = iminmax_temp(:,2,k) 
     467 
     468C                datasize = 1 
     469C 
     470C                do i = 1,nbdim 
     471C 
     472C                datasize = datasize * (imax_recv(i,k)-imin_recv(i,k)+1) 
     473C 
     474C                enddo 
     475             IF (.Not.Associated(temprecv%var)) allocate(temprecv%var) 
     476             call Agrif_nbdim_allocation(temprecv%var, 
     477     &   iminmax_temp(:,1,k),iminmax_temp(:,2,k),nbdim) 
    463478            SELECT CASE(nbdim) 
    464479            CASE(1) 
     480              datasize=SIZE(temprecv%var%array1) 
    465481              Call MPI_RECV(temprecv%var%array1, 
    466482     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
    467483     &               MPI_COMM_WORLD,statut,code) 
    468484            CASE(2) 
     485              datasize=SIZE(temprecv%var%array2) 
    469486              Call MPI_RECV(temprecv%var%array2, 
    470487     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
    471488     &               MPI_COMM_WORLD,statut,code) 
    472489            CASE(3) 
     490              datasize=SIZE(temprecv%var%array3) 
    473491              Call MPI_RECV(temprecv%var%array3, 
    474492     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
     
    476494 
    477495            CASE(4) 
     496              datasize=SIZE(temprecv%var%array4) 
    478497              Call MPI_RECV(temprecv%var%array4, 
    479498     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
    480499     &               MPI_COMM_WORLD,statut,code) 
    481500            CASE(5) 
     501              datasize=SIZE(temprecv%var%array5) 
    482502              Call MPI_RECV(temprecv%var%array5, 
    483503     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
    484504     &               MPI_COMM_WORLD,statut,code) 
    485505            CASE(6) 
     506              datasize=SIZE(temprecv%var%array6) 
    486507              Call MPI_RECV(temprecv%var%array6, 
    487508     &               datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
     
    490511             
    491512            Call where_valtabtotab_mpi(tempCextend%var, 
    492      &             temprecv%var,imin_recv(:,k),imax_recv(:,k),0.,nbdim) 
     513     &             temprecv%var,iminmax_temp(:,1,k),iminmax_temp(:,2,k) 
     514     &            ,0.,nbdim) 
    493515      
    494516                Call Agrif_nbdim_deallocation(temprecv%var,nbdim) 
    495                 deallocate(temprecv%var) 
     517C                deallocate(temprecv%var) 
    496518            endif 
    497519 
     
    500522 
    501523          End Subroutine ExchangeSamelevel 
     524 
     525          Subroutine Agrif_Send_3Darray(tab3D,bounds,imin,imax,k) 
     526          integer, dimension(3) :: bounds, imin, imax 
     527          real,dimension(bounds(1):,bounds(2):,bounds(3):),target 
     528     &                             :: tab3D 
     529          integer :: k 
     530          integer :: etiquette = 100 
     531          integer :: datasize, code 
     532#include "mpif.h"    
     533 
     534          datasize = SIZE(tab3D( 
     535     &                       imin(1):imax(1), 
     536     &                        imin(2):imax(2), 
     537     &                        imin(3):imax(3))) 
     538        
     539                   Call MPI_SEND(tab3D( 
     540     &                        imin(1):imax(1), 
     541     &                        imin(2):imax(2), 
     542     &                        imin(3):imax(3)), 
     543     &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette, 
     544     &                        MPI_COMM_WORLD,code) 
     545      
     546         End Subroutine Agrif_Send_3Darray 
    502547 
    503548#else 
  • trunk/AGRIF/AGRIF_FILES/modsauv.F

    r396 r662  
    156156               Deallocate(Agrif_Gr%tabvars(i)%var%interpIndex) 
    157157            endif 
     158             
     159            if (associated(Agrif_Gr%tabvars(i)%var%posvar)) then 
     160               Deallocate(Agrif_Gr%tabvars(i)%var%posvar) 
     161            endif      
     162             
     163            if (associated(Agrif_Gr%tabvars(i)%var%interptab)) then 
     164               Deallocate(Agrif_Gr%tabvars(i)%var%interptab) 
     165            endif   
     166                              
    158167C 
    159168            Deallocate(Agrif_Gr%tabvars(i)%var) 
     
    291300               Deallocate(Agrif_Gr%tabvars(i)%var%interpIndex) 
    292301            endif 
     302             
     303            if (associated(Agrif_Gr%tabvars(i)%var%posvar)) then 
     304               Deallocate(Agrif_Gr%tabvars(i)%var%posvar) 
     305            endif      
     306             
     307            if (associated(Agrif_Gr%tabvars(i)%var%interptab)) then 
     308               Deallocate(Agrif_Gr%tabvars(i)%var%interptab) 
     309            endif               
    293310! 
    294311            Deallocate(Agrif_Gr%tabvars(i)%var) 
     
    349366            eps = min(g_eps,oldgrid_eps)/100.                   
    350367C 
     368            do iii = 1 , Agrif_Probdim 
    351369 
    352             do iii = 1 , Agrif_Probdim 
    353370               if (g % Agrif_d(iii) .LT.  
    354371     &             (parcours % gr % Agrif_d(iii) - eps)) then 
     
    358375                   out = 1 
    359376C    
    360                    Cycle 
     377                   Exit 
    361378C              
    362379               endif 
  • trunk/AGRIF/AGRIF_FILES/modtypes.F

    r396 r662  
    2929C 
    3030      IMPLICIT NONE 
     31       
     32C     Maximum refinement ratio 
     33 
     34      INTEGER, PARAMETER :: Agrif_MaxRaff = 7       
    3135C 
    3236C     ************************************************************************** 
     
    156160           INTEGER ,DIMENSION(:,:)        ,Pointer :: tabpoint2D 
    157161           INTEGER ,DIMENSION(:,:,:)      ,Pointer :: tabpoint3D 
     162            
     163           Type(Agrif_Flux), Pointer               :: fluxes => NULL() 
    158164      End TYPE Agrif_grid 
    159165C 
     
    191197         REAL   , DIMENSION(:,:,:,:,:,:),Pointer :: array6    => NULL() 
    192198C        Arrays containing the values of the grid variables (REAL*8) 
    193          REAL(8)                                 :: darray0 
    194          REAL(8), DIMENSION(:)          ,Pointer :: darray1   => NULL() 
    195          REAL(8), DIMENSION(:,:)        ,Pointer :: darray2   => NULL() 
    196          REAL(8), DIMENSION(:,:,:)      ,Pointer :: darray3   => NULL() 
    197          REAL(8), DIMENSION(:,:,:,:)    ,Pointer :: darray4   => NULL() 
    198          REAL(8), DIMENSION(:,:,:,:,:)  ,Pointer :: darray5   => NULL() 
    199          REAL(8), DIMENSION(:,:,:,:,:,:),Pointer :: darray6   => NULL() 
     199         REAL*8                                 :: darray0 
     200         REAL*8, DIMENSION(:)          ,Pointer :: darray1   => NULL() 
     201         REAL*8, DIMENSION(:,:)        ,Pointer :: darray2   => NULL() 
     202         REAL*8, DIMENSION(:,:,:)      ,Pointer :: darray3   => NULL() 
     203         REAL*8, DIMENSION(:,:,:,:)    ,Pointer :: darray4   => NULL() 
     204         REAL*8, DIMENSION(:,:,:,:,:)  ,Pointer :: darray5   => NULL() 
     205         REAL*8, DIMENSION(:,:,:,:,:,:),Pointer :: darray6   => NULL() 
    200206C        Arrays containing the values of the grid variables (LOGICAL) 
    201207         LOGICAL                                 :: larray0 
     
    240246         INTEGER, DIMENSION(6) :: TYPEinterp ! option interp 
    241247         INTEGER, DIMENSION(6) :: TYPEupdate ! option update 
    242 C 
    243       End TYPE Agrif_Variable    
     248          
     249         Type(Agrif_List_Interp_Loc), Pointer :: list_interp => NULL() 
     250         Type(Agrif_List_Interp_Loc), Pointer :: list_update => NULL() 
     251C 
     252      End TYPE Agrif_Variable  
     253       
     254      Type Agrif_Interp_Loc 
     255      integer,dimension(6) :: pttab,petab, 
     256     &                          pttab_Child,pttab_Parent = -99 
     257      integer,dimension(6) :: indmin, indmax 
     258      INTEGER,DIMENSION(6)    :: pttruetab,cetruetab 
     259      logical :: member, memberin       
     260#if !defined AGRIF_MPI       
     261      integer,dimension(6) :: indminglob,indmaxglob 
     262#else 
     263      integer,dimension(6) :: indminglob2,indmaxglob2 
     264      INTEGER,DIMENSION(6,2,2) :: parentarray 
     265      INTEGER,DIMENSION(:,:,:), POINTER :: tab4t 
     266      LOGICAL, DIMENSION(:), POINTER :: memberinall 
     267      INTEGER,DIMENSION(:,:,:), POINTER :: tab5t 
     268      LOGICAL, DIMENSION(:), POINTER :: memberinall2 
     269#endif       
     270      End Type Agrif_Interp_Loc 
     271       
     272      Type Agrif_List_Interp_Loc 
     273      Type(Agrif_Interp_Loc), Pointer :: interp_loc 
     274      Type(Agrif_List_Interp_Loc), Pointer :: suiv 
     275      End Type Agrif_List_Interp_Loc 
     276         
     277       TYPE Agrif_Profile 
     278          character*80 :: profilename 
     279C 
     280         ! index of the first point in the REAL domain (x,y and z direction) 
     281         INTEGER     ,DIMENSION(6)          :: point 
     282         ! position of the variable on the cell (1 for the boarder of  
     283         !    the edge, 2 for the center) 
     284         INTEGER     ,DIMENSION(:) ,Pointer :: posvar      => NULL()  
     285         ! Indication for the space interpolation (module Agrif_Boundary) 
     286         INTEGER                   ,Pointer :: interpIndex => NULL()  
     287         ! number of DIMENSIONs of the grid variable 
     288         INTEGER                            :: nbdim = 0              
     289         ! Array indicating the TYPE of DIMENSION (space or not) for  
     290         !    each of them  
     291         CHARACTER(6),DIMENSION(:) ,Pointer :: interptab   => NULL()  
     292         Type(Agrif_Profile), Pointer :: nextprofile  => NULL() 
     293       END TYPE Agrif_Profile 
     294        
     295       Type(Agrif_Profile), Pointer :: Agrif_MyProfiles => NULL() 
     296            
     297C  Boundaries Fluxes 
     298 
     299      Type Agrif_Flux 
     300        Character*80 fluxname 
     301        Type(Agrif_Variable), Pointer :: fluxtabx 
     302        Type(Agrif_Variable), Pointer :: fluxtaby 
     303        Type(Agrif_Variable), Pointer :: fluxtabz         
     304        Type(Agrif_Profile), Pointer  :: profile 
     305        Logical :: Fluxallocated = .FALSE. 
     306        Type(Agrif_Flux), Pointer     :: nextflux => NULL() 
     307      End Type Agrif_Flux       
    244308C 
    245309C     ************************************************************************** 
     
    285349      INTEGER               :: Agrif_Regridding 
    286350      INTEGER               :: Agrif_Minwidth 
    287       REAL                  :: Agrif_Efficiency 
     351      REAL                  :: Agrif_Efficiency = 0.7 
    288352      REAL    ,DIMENSION(3) :: Agrif_mind 
    289353C     PARAMETERs for the interpolation of the child grids 
     
    302366      ! linear conservative interpolation        
    303367      INTEGER ,PARAMETER    :: Agrif_linearconservlim=7 
    304       INTEGER ,PARAMETER    :: Agrif_ppm=8     
     368      INTEGER ,PARAMETER    :: Agrif_ppm=8  
     369      INTEGER ,PARAMETER    :: Agrif_weno=9          
    305370C     PARAMETERs for the update of the parent grids       
    306371      INTEGER ,PARAMETER    :: Agrif_Update_Copy=1           ! copy 
  • trunk/AGRIF/AGRIF_FILES/modupdate.F

    r396 r662  
    8585C       
    8686C     Values on the current grid used for the update 
    87       childtemp % var % array1 => tab       
     87      childtemp % var % array1 => tab      
     88       
     89C      childtemp % var % list_update => child%var%list_update 
     90              
    8891C 
    8992      
     
    9699      ENDIF      
    97100C       
     101C      child % var % list_update => childtemp%var%list_update 
     102       
    98103      deallocate(childtemp % var) 
    99104C 
     
    146151C     Values on the current grid used for the update 
    147152      childtemp % var % array2 => tab       
     153       
     154C      childtemp % var % list_update => child%var%list_update       
    148155C 
    149156      IF (present(procname)) THEN 
     
    155162      ENDIF 
    156163C       
     164C      child % var % list_update => childtemp%var%list_update 
     165       
    157166      deallocate(childtemp % var) 
    158167C 
     
    204213C     Values on the current grid used for the update 
    205214      childtemp % var % array3 => tab      
     215       
     216C      childtemp % var % list_update => child%var%list_update       
    206217C 
    207218      IF (present(procname)) THEN 
     
    213224      ENDIF 
    214225C       
     226C      child % var % list_update => childtemp%var%list_update 
     227       
    215228      DEALLOCATE(childtemp % var) 
    216229C 
     
    262275C     Values on the current grid used for the update 
    263276      childtemp % var % array4 => tab      
     277       
     278C      childtemp % var % list_update => child%var%list_update 
     279             
    264280C 
    265281      IF (present(procname)) THEN 
     
    270286     &     (TypeUpdate,parent,child,deb,fin) 
    271287      ENDIF 
     288 
     289C      child % var % list_update => childtemp%var%list_update       
    272290C 
    273291      deallocate(childtemp % var) 
     
    322340C     Values on the current grid used for the update 
    323341      childtemp % var % array5 => tab       
     342       
     343C      childtemp % var % list_update => child%var%list_update       
    324344C 
    325345      IF (present(procname)) THEN 
     
    330350     &     (TypeUpdate,parent,child,deb,fin) 
    331351      ENDIF 
     352       
     353C      child % var % list_update => childtemp%var%list_update 
     354             
    332355C       
    333356      deallocate(childtemp % var) 
     
    380403C     Values on the current grid used for the update 
    381404      childtemp % var % array6 => tab       
     405C      childtemp % var % list_update => child%var%list_update 
    382406C 
    383407      Call Agrif_UpdateVariable 
    384408     &     (TypeUpdate,parent,child,deb,fin) 
     409      
     410C      child % var % list_update => childtemp%var%list_update 
     411            
    385412C       
    386413      deallocate(childtemp % var) 
     
    658685 
    659686        IF (posvartab_child(i) == 1) THEN 
    660           IF (TypeUpdate(i) .NE. Agrif_Update_Copy) THEN 
     687          IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN 
     688            indtab(i,1,1) = indtab(i,1,1) - (coeffraf - 1) 
     689            indtab(i,1,2) = indtab(i,1,2) + (coeffraf - 1)         
     690          ELSE IF (TypeUpdate(i) .NE. Agrif_Update_Copy) THEN 
    661691            indtab(i,1,1) = indtab(i,1,1) - coeffraf / 2 
    662692            indtab(i,1,2) = indtab(i,1,2) + coeffraf / 2 
     
    665695          indtab(i,1,1) = indtab(i,1,1) - coeffraf 
    666696          indtab(i,1,2) = indtab(i,1,2) - 1 
     697          IF ((TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) 
     698     &                            .AND.(mod(coeffraf,2) == 1)) THEN 
     699            indtab(i,1,1) = indtab(i,1,1) - 1 
     700            indtab(i,1,2) = indtab(i,1,2) + 1 
     701          ENDIF 
    667702        ENDIF 
    668703        IF (loctab_child(i) == -3) THEN 
     
    832867 
    833868        IF (posvartab_child(i) == 1) THEN 
    834           IF (TypeUpdate(i) .NE. Agrif_Update_Copy) THEN 
     869          IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN 
     870            indtab(i,:,1) = indtab(i,:,1) - (coeffraf - 1) 
     871            indtab(i,:,2) = indtab(i,:,2) + (coeffraf - 1)         
     872          ELSE IF (TypeUpdate(i) .NE. Agrif_Update_Copy) THEN 
    835873            indtab(i,:,1) = indtab(i,:,1) - coeffraf / 2 
    836874            indtab(i,:,2) = indtab(i,:,2) + coeffraf / 2 
     
    840878          indtab(i,1,2) = indtab(i,1,2) - 1 
    841879          indtab(i,2,2) = indtab(i,2,2) + coeffraf - 1 
     880          IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN 
     881            indtab(i,1,1) = indtab(i,1,1) - 1 
     882            indtab(i,1,2) = indtab(i,1,2) + 1 
     883            indtab(i,2,1) = indtab(i,2,1) - 1 
     884            indtab(i,2,2) = indtab(i,2,2) + 1 
     885          ENDIF           
    842886        ENDIF 
    843887      ENDDO 
     
    952996     &              ds_Child(1:nbdim),ds_Parent(1:nbdim), 
    953997     &              posvartab_Child,loctab_Child, 
    954      &              nbdim,procname) 
     998     &              nbdim,procname,nb,ndir) 
    955999           ELSE 
    9561000              Call Agrif_UpdatenD               
     
    9851029     &                          ds_Child,ds_Parent, 
    9861030     &                          posvartab_Child,loctab_Child, 
    987      &                          nbdim,procname 
     1031     &                          nbdim,procname,nb,ndir 
    9881032C 
    9891033C     Description: 
     
    10301074      External :: procname 
    10311075      Optional ::  procname 
     1076      Integer :: nb,ndir 
     1077      Optional :: nb,ndir 
     1078       
    10321079C 
    10331080C     Local pointers 
    1034       TYPE(AGRIF_PVARIABLE)      :: tempP      ! Temporary parent grid variable 
    1035       TYPE(AGRIF_PVARIABLE)      :: tempC      ! Temporary child grid variable 
     1081      TYPE(AGRIF_PVARIABLE), SAVE      :: tempP      ! Temporary parent grid variable 
     1082      TYPE(AGRIF_PVARIABLE), SAVE      :: tempC      ! Temporary child grid variable 
    10361083C 
    10371084C     Local scalars 
     
    10471094      INTEGER,DIMENSION(nbdim,2,2) :: childarray 
    10481095      INTEGER,DIMENSION(nbdim,2,2) :: parentarray 
    1049       TYPE(AGRIF_PVARIABLE)      :: tempCextend,tempPextend ! Temporary child 
    1050                                                             !    grid 
     1096      TYPE(AGRIF_PVARIABLE), SAVE      :: tempCextend,tempPextend ! Temporary child 
     1097      INTEGER :: nbin, ndirin 
    10511098C 
    10521099#ifdef AGRIF_MPI 
     
    10571104      INTEGER,DIMENSION(nbdim,4)           :: tab3 
    10581105      INTEGER,DIMENSION(nbdim,4,0:Agrif_Nbprocs-1) :: tab4 
    1059       INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,4) :: tab4t 
    1060 ccccccccccccccc      TYPE(AGRIF_PVARIABLE)                :: childvalues 
     1106      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,4) :: tab4t, tab5t 
     1107      LOGICAL :: find_list_update 
     1108      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: memberinall, memberinall2 
     1109      LOGICAL, DIMENSION(1) :: memberin1       
    10611110C 
    10621111#endif 
     
    11191168#endif 
    11201169 
    1121  
     1170       IF (present(procname)) THEN 
     1171       IF (.Not.present(nb)) THEN 
     1172       nbin=0 
     1173       ndirin=0 
     1174       ELSE 
     1175       nbin = nb 
     1176       ndirin = ndir 
     1177       ENDIF 
     1178       ENDIF 
     1179        
    11221180      IF (memberin) THEN 
    1123       allocate(tempC%var) 
     1181      IF (.not.associated(tempC%var)) allocate(tempC%var) 
    11241182 
    11251183C 
     
    11361194          CALL procname(tempC%var%array1, 
    11371195     &                          childarray(1,1,2),childarray(1,2,2), 
    1138      &                                   .TRUE.) 
     1196     &                                   .TRUE.,nbin,ndirin) 
    11391197        CASE(2) 
    11401198          CALL procname(tempC%var%array2, 
    11411199     &                          childarray(1,1,2),childarray(1,2,2), 
    11421200     &                          childarray(2,1,2),childarray(2,2,2), 
    1143      &                                   .TRUE.) 
     1201     &                                   .TRUE.,nbin,ndirin) 
    11441202        CASE(3) 
    11451203          CALL procname(tempC%var%array3, 
     
    11471205     &                          childarray(2,1,2),childarray(2,2,2), 
    11481206     &                          childarray(3,1,2),childarray(3,2,2), 
    1149      &                                   .TRUE.) 
     1207     &                                   .TRUE.,nbin,ndirin) 
    11501208        CASE(4) 
    11511209          CALL procname(tempC%var%array4, 
     
    11541212     &                          childarray(3,1,2),childarray(3,2,2), 
    11551213     &                          childarray(4,1,2),childarray(4,2,2), 
    1156      &                                   .TRUE.) 
     1214     &                                   .TRUE.,nbin,ndirin) 
    11571215        CASE(5) 
    11581216          CALL procname(tempC%var%array5, 
     
    11621220     &                          childarray(4,1,2),childarray(4,2,2), 
    11631221     &                          childarray(5,1,2),childarray(5,2,2), 
    1164      &                                   .TRUE.) 
     1222     &                                   .TRUE.,nbin,ndirin) 
    11651223        CASE(6) 
    11661224          CALL procname(tempC%var%array6, 
     
    11711229     &                          childarray(5,1,2),childarray(5,2,2), 
    11721230     &                          childarray(6,1,2),childarray(6,2,2), 
    1173      &                                   .TRUE.) 
     1231     &                                   .TRUE.,nbin,ndirin) 
    11741232        END SELECT 
    11751233      ELSE 
     
    11891247C     tab2 contains the necessary limits of the parent grid for each processor 
    11901248 
     1249      IF (Associated(child%var%list_update)) THEN 
     1250      Call Agrif_Find_list_update(child%var%list_update,pttab,petab, 
     1251     &                          pttab_Child,pttab_Parent,nbdim, 
     1252     &       find_list_update,tab4t,tab5t,memberinall,memberinall2) 
     1253      ELSE 
     1254      find_list_update = .FALSE. 
     1255      ENDIF 
     1256       
     1257      if (.not.find_list_update) then       
    11911258      tab3(:,1) = pttruetab(:) 
    11921259      tab3(:,2) = cetruetab(:) 
     
    11981265     &                   MPI_INTEGER,MPI_COMM_WORLD,code) 
    11991266 
    1200       Allocate(tempCextend%var) 
     1267      IF (.not.associated(tempCextend%var)) Allocate(tempCextend%var) 
    12011268      DO k=0,Agrif_Nbprocs-1 
    12021269       do j=1,4 
     
    12061273       enddo 
    12071274      enddo 
     1275       
     1276      memberin1(1) = memberin 
     1277      CALL MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall, 
     1278     &                  1,MPI_LOGICAL,MPI_COMM_WORLD,code) 
     1279            
     1280      endif 
     1281       
    12081282      Call Get_External_Data(tempC,tempCextend,tab4t(:,:,1), 
    12091283     &            tab4t(:,:,2), 
    1210      &            tab4t(:,:,3),tab4t(:,:,4),nbdim,memberin,memberin) 
     1284     &            tab4t(:,:,3),tab4t(:,:,4),nbdim,memberin,memberin, 
     1285     &            memberinall) 
    12111286 
    12121287#else 
     
    12211296      IF (memberin) THEN 
    12221297 
    1223       allocate(tempP%var) 
     1298      IF (.not.associated(tempP%var)) allocate(tempP%var) 
    12241299      Call Agrif_nbdim_allocation(tempP%var, 
    12251300     &                 indmin,indmax,nbdim) 
     
    12761351 
    12771352      Call Agrif_nbdim_deallocation(tempCextend%var,nbdim) 
    1278       Deallocate(tempCextend%var) 
     1353C      Deallocate(tempCextend%var) 
    12791354 
    12801355      ENDIF 
     
    13011376      Call Agrif_ParentGrid_to_ChildGrid() 
    13021377 
     1378      if (.not.find_list_update) then 
    13031379      tab3(:,1) = indmin(:) 
    13041380      tab3(:,2) = indmax(:) 
     
    13091385     &                   MPI_INTEGER,MPI_COMM_WORLD,code) 
    13101386 
    1311       Allocate(tempPextend%var) 
     1387      IF (.not.associated(tempPextend%var)) Allocate(tempPextend%var) 
    13121388      DO k=0,Agrif_Nbprocs-1 
    13131389       do j=1,4 
    13141390         do i=1,nbdim 
    1315          tab4t(i,k,j) = tab4(i,j,k) 
     1391         tab5t(i,k,j) = tab4(i,j,k) 
    13161392         enddo 
    13171393       enddo 
    13181394      enddo 
    1319       Call Get_External_Data(tempP,tempPextend,tab4t(:,:,1), 
    1320      &            tab4t(:,:,2), 
    1321      &            tab4t(:,:,3),tab4t(:,:,4),nbdim,memberin,member) 
     1395  
     1396      memberin1(1) = member 
     1397      CALL MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall2, 
     1398     &                  1,MPI_LOGICAL,MPI_COMM_WORLD,code) 
     1399      
     1400      Call Agrif_Addto_list_update(child%var%list_update,pttab,petab, 
     1401     &                          pttab_Child,pttab_Parent,nbdim 
     1402     &   ,tab4t,tab5t,memberinall,memberinall2)  
     1403           
     1404      endif 
     1405       
     1406      Call Get_External_Data(tempP,tempPextend,tab5t(:,:,1), 
     1407     &            tab5t(:,:,2), 
     1408     &            tab5t(:,:,3),tab5t(:,:,4),nbdim,memberin,member, 
     1409     &            memberinall2) 
    13221410 
    13231411#else 
     
    14071495     &                      parentarray(1,1,1):parentarray(1,2,1)), 
    14081496     &                      parentarray(1,1,2),parentarray(1,2,2), 
    1409      &                                   .FALSE. 
     1497     &                                   .FALSE.,nbin,ndirin 
    14101498     &                      ) 
    14111499            CASE(2) 
     
    14161504     &                      parentarray(1,1,2),parentarray(1,2,2), 
    14171505     &                      parentarray(2,1,2),parentarray(2,2,2), 
    1418      &                                   .FALSE. 
     1506     &                                   .FALSE.,nbin,ndirin 
    14191507     &                      ) 
    14201508            CASE(3) 
     
    14271515     &                      parentarray(2,1,2),parentarray(2,2,2), 
    14281516     &                      parentarray(3,1,2),parentarray(3,2,2), 
    1429      &                                   .FALSE. 
     1517     &                                   .FALSE.,nbin,ndirin 
    14301518     &                      ) 
    14311519            CASE(4) 
     
    14401528     &                      parentarray(3,1,2),parentarray(3,2,2), 
    14411529     &                      parentarray(4,1,2),parentarray(4,2,2), 
    1442      &                                   .FALSE. 
     1530     &                                   .FALSE.,nbin,ndirin 
    14431531     &                      ) 
    14441532            CASE(5) 
     
    14551543     &                      parentarray(4,1,2),parentarray(4,2,2), 
    14561544     &                      parentarray(5,1,2),parentarray(5,2,2), 
    1457      &                                   .FALSE. 
     1545     &                                   .FALSE.,nbin,ndirin 
    14581546     &                      ) 
    14591547            CASE(6) 
     
    14721560     &                      parentarray(5,1,2),parentarray(5,2,2), 
    14731561     &                      parentarray(6,1,2),parentarray(6,2,2), 
    1474      &                                   .FALSE. 
     1562     &                                   .FALSE.,nbin,ndirin 
    14751563     &                      ) 
    14761564            END SELECT 
     
    15451633      Call Agrif_nbdim_deallocation(tempP%var,nbdim) 
    15461634      Call Agrif_nbdim_deallocation(tempC%var,nbdim) 
    1547       Deallocate(tempC % var) 
     1635!      Deallocate(tempC % var) 
    15481636#endif 
    1549       Deallocate(tempP % var) 
     1637!      Deallocate(tempP % var) 
    15501638      ENDIF 
    15511639#ifdef AGRIF_MPI 
    1552       Deallocate(tempPextend%var) 
    1553       IF (.Not.memberin) Deallocate(tempCextend%var) 
     1640!      Deallocate(tempPextend%var) 
     1641!      IF (.Not.memberin) Deallocate(tempCextend%var) 
    15541642#endif 
    15551643 
     
    16281716        IF (loctab_Child(i) .NE. -3) THEN 
    16291717        IF (posvartab_child(i) == 1) THEN 
    1630           IF (TypeUpdate(i) .NE. Agrif_Update_Copy) THEN 
    1631         positionmin = positionmin - ds_Parent(i)/2. 
     1718          IF (TypeUpdate(i) .EQ. Agrif_Update_Average) THEN 
     1719          positionmin = positionmin - ds_Parent(i)/2. 
     1720          ELSE IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN 
     1721          positionmin = positionmin - (ds_Parent(i)-ds_Child(i)) 
    16321722          ENDIF 
    16331723        ELSE 
    16341724        positionmin = positionmin - ds_Parent(i)/2. 
     1725        IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN 
     1726          positionmin = positionmin - ds_Child(i) 
     1727        ENDIF 
    16351728        ENDIF 
    16361729        ENDIF 
     
    16471740        IF (loctab_Child(i) .NE. -3) THEN 
    16481741        IF (posvartab_child(i) == 1) THEN 
    1649           IF (TypeUpdate(i) .NE. Agrif_Update_Copy) THEN 
     1742          IF (TypeUpdate(i) .EQ. Agrif_Update_Average) THEN 
    16501743        positionmax = positionmax  + ds_Parent(i)/2. 
     1744          ELSE IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN 
     1745          positionmax = positionmax  + (ds_Parent(i)-ds_Child(i)) 
    16511746          ENDIF 
    16521747        ELSE 
    16531748        positionmax = positionmax  + ds_Parent(i)/2. 
     1749        IF (TypeUpdate(i) .EQ. Agrif_Update_Full_Weighting) THEN 
     1750          positionmax = positionmax + ds_Child(i) 
     1751        ENDIF         
    16541752        ENDIF 
    16551753        ENDIF 
     
    16841782C 
    16851783C 
    1686 C     ************************************************************************** 
    1687 CCC   Subroutine Agrif_Update_1D_Recursive 
    1688 C     ************************************************************************** 
    1689 C 
    1690       Subroutine Agrif_Update_1D_recursive(TypeUpdate,tempP,tempC, 
    1691      &                                     indmin,indmax, 
    1692      &                                     pttab_child,petab_child, 
    1693      &                                     s_child,s_parent, 
    1694      &                                     ds_child,ds_parent,nbdim) 
    1695 C 
    1696 CCC   Description: 
    1697 CCC   Subroutine to update a 1D grid variable on the parent grid. 
    1698 C 
    1699 CC    Method: 
    1700 C 
    1701 C     Declarations: 
    1702 C 
    1703        
    1704 C 
    1705 C     Arguments 
    1706       INTEGER                   :: nbdim 
    1707       INTEGER, DIMENSION(nbdim) :: TypeUpdate            ! TYPE of update (copy or average) 
    1708       INTEGER, DIMENSION(nbdim) :: indmin,indmax 
    1709       INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child 
    1710       REAL, DIMENSION(nbdim)    :: s_child,s_parent 
    1711       REAL, DIMENSION(nbdim)    :: ds_child,ds_parent 
    1712       REAL, DIMENSION(indmin(nbdim):indmax(nbdim))           :: tempP 
    1713       REAL, DIMENSION(pttab_child(nbdim):petab_child(nbdim)) :: tempC 
    1714 C 
    1715 C 
    1716       Call Agrif_UpdateBase(TypeUpdate(1), 
    1717      &                  tempP(indmin(nbdim):indmax(nbdim)), 
    1718      &                  tempC(pttab_child(nbdim):petab_child(nbdim)), 
    1719      &                  indmin(nbdim),indmax(nbdim),            
    1720      &                  pttab_child(nbdim),petab_child(nbdim), 
    1721      &                  s_parent(nbdim),s_child(nbdim), 
    1722      &                  ds_parent(nbdim),ds_child(nbdim)) 
    1723 C 
    1724       Return 
    1725 C 
    1726 C 
    1727       End Subroutine Agrif_Update_1D_recursive 
     1784 
    17281785C 
    17291786C 
     
    17341791C 
    17351792      Subroutine Agrif_Update_2D_recursive(TypeUpdate,tempP,tempC, 
    1736      &                                     indmin,indmax,    
     1793     &                                     indmin,indmax, 
    17371794     &                                     pttab_child,petab_child, 
    17381795     &                                     s_child,s_parent, 
     
    17571814      REAL, DIMENSION(indmin(1):indmax(1), 
    17581815     &                indmin(2):indmax(2))           :: tempP 
    1759       REAL, DIMENSION(pttab_child(1):petab_child(1), 
    1760      &                pttab_child(2):petab_child(2)) :: tempC 
     1816C      REAL, DIMENSION(pttab_child(1):petab_child(1), 
     1817C     &                pttab_child(2):petab_child(2)) :: tempC 
     1818      
     1819      REAL, DIMENSION(:,:) :: tempC      
    17611820C 
    17621821C     Local variables       
    1763       REAL, DIMENSION(:,:), Allocatable :: tabtemp 
     1822      REAL, DIMENSION(indmin(1):indmax(1), 
     1823     &                 pttab_child(2):petab_child(2)) :: tabtemp 
    17641824      INTEGER :: i,j 
    1765 C 
    1766 C 
    1767       Allocate(tabtemp(indmin(1):indmax(1), 
    1768      &                 pttab_child(2):petab_child(2))) 
     1825      INTEGER :: coeffraf,locind_child_left 
    17691826C 
    17701827      do j = pttab_child(nbdim),petab_child(nbdim) 
    17711828C 
    1772         Call Agrif_Update_1D_recursive(TypeUpdate,     
    1773      &         tabtemp(indmin(nbdim-1):indmax(nbdim-1),j), 
    1774      &         tempC(pttab_child(nbdim-1):petab_child(nbdim-1),j), 
     1829        Call Agrif_Update_1D_recursive(TypeUpdate(1:nbdim-1),     
     1830     &         tabtemp(:,j), 
     1831     &         tempC(:,j-pttab_child(nbdim)+1), 
    17751832     &         indmin(1:nbdim-1),indmax(1:nbdim-1), 
    17761833     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1), 
     
    17791836C 
    17801837      enddo 
     1838       
     1839      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim), 
     1840     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left) 
    17811841C 
    17821842      do i = indmin(1),indmax(1) 
    17831843C 
    17841844        Call Agrif_UpdateBase(TypeUpdate(2), 
    1785      &           tempP(i,indmin(nbdim):indmax(nbdim)), 
    1786      &          tabtemp(i,pttab_child(nbdim):petab_child(nbdim)), 
     1845     &           tempP(i,:), 
     1846     &          tabtemp(i,:), 
    17871847     &           indmin(nbdim),indmax(nbdim), 
    17881848     &           pttab_child(nbdim),petab_child(nbdim), 
    17891849     &           s_parent(nbdim),s_child(nbdim), 
    1790      &           ds_parent(nbdim),ds_child(nbdim)) 
     1850     &           ds_parent(nbdim),ds_child(nbdim), 
     1851     &                  coeffraf,locind_child_left) 
    17911852C         
    17921853      enddo 
    1793 C 
    1794       Deallocate(tabtemp) 
    17951854C 
    17961855      Return 
     
    18351894C 
    18361895C     Local variables       
    1837       REAL, DIMENSION(:,:,:), Allocatable :: tabtemp 
     1896      REAL, DIMENSION(indmin(1):indmax(1), 
     1897     &                 indmin(2):indmax(2),  
     1898     &                 pttab_child(3):petab_child(3)) :: tabtemp 
    18381899      INTEGER :: i,j,k 
    1839 C 
    1840 C 
    1841       Allocate(tabtemp(indmin(1):indmax(1), 
    1842      &                 indmin(2):indmax(2),  
    1843      &                 pttab_child(3):petab_child(3))) 
     1900      INTEGER :: coeffraf,locind_child_left 
     1901      INTEGER :: kdeb 
     1902C 
    18441903C 
    18451904      do k = pttab_child(nbdim),petab_child(nbdim) 
    18461905C 
    1847         Call Agrif_Update_2D_recursive(TypeUpdate,     
    1848      &         tabtemp(indmin(nbdim-2):indmax(nbdim-2), 
    1849      &                 indmin(nbdim-1):indmax(nbdim-1),k), 
    1850      &         tempC(pttab_child(nbdim-2):petab_child(nbdim-2), 
    1851      &               pttab_child(nbdim-1):petab_child(nbdim-1),k), 
     1906        Call Agrif_Update_2D_recursive(TypeUpdate(1:nbdim-1),     
     1907     &         tabtemp(:,:,k), 
     1908     &         tempC(:,:,k), 
    18521909     &         indmin(1:nbdim-1),indmax(1:nbdim-1), 
    18531910     &         pttab_child(1:nbdim-1),petab_child(1:nbdim-1), 
     
    18571914      enddo 
    18581915C 
    1859 C 
     1916      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim), 
     1917     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left) 
     1918       
     1919      IF (coeffraf == 1) THEN 
     1920       
     1921      kdeb = pttab_child(3)+locind_child_left-2 
     1922      do k=indmin(3),indmax(3) 
     1923      kdeb = kdeb + 1 
    18601924      do j = indmin(2),indmax(2) 
    1861 C 
    18621925        do i = indmin(1),indmax(1) 
     1926        tempP(i,j,k) = tabtemp(i,j,kdeb) 
     1927      enddo 
     1928      enddo 
     1929      enddo 
     1930               
     1931      ELSE 
     1932C 
     1933      do j = indmin(2),indmax(2) 
     1934C 
     1935        do i = indmin(1),indmax(1) 
    18631936C 
    18641937          Call Agrif_UpdateBase(TypeUpdate(3), 
    1865      &           tempP(i,j,indmin(nbdim):indmax(nbdim)), 
    1866      &          tabtemp(i,j,pttab_child(nbdim):petab_child(nbdim)), 
     1938     &           tempP(i,j,:), 
     1939     &          tabtemp(i,j,:), 
    18671940     &           indmin(nbdim),indmax(nbdim), 
    18681941     &           pttab_child(nbdim),petab_child(nbdim), 
    18691942     &           s_parent(nbdim),s_child(nbdim), 
    1870      &           ds_parent(nbdim),ds_child(nbdim)) 
     1943     &           ds_parent(nbdim),ds_child(nbdim), 
     1944     &                  coeffraf,locind_child_left) 
    18711945C 
    18721946        enddo  
    18731947C         
    18741948      enddo 
    1875 C 
    1876       Deallocate(tabtemp) 
     1949      ENDIF 
    18771950C 
    18781951      Return 
     
    19211994      REAL, DIMENSION(:,:,:,:), Allocatable :: tabtemp 
    19221995      INTEGER :: i,j,k,l 
     1996      INTEGER :: coeffraf,locind_child_left 
    19231997C 
    19241998C 
     
    19302004      do l = pttab_child(nbdim),petab_child(nbdim) 
    19312005C 
    1932         Call Agrif_Update_3D_recursive(TypeUpdate,     
     2006        Call Agrif_Update_3D_recursive(TypeUpdate(1:nbdim-1),     
    19332007     &         tabtemp(indmin(nbdim-3):indmax(nbdim-3), 
    19342008     &                 indmin(nbdim-2):indmax(nbdim-2), 
     
    19432017C 
    19442018      enddo 
     2019       
     2020      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim), 
     2021     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left) 
    19452022C 
    19462023      do k = indmin(3),indmax(3) 
     
    19562033     &           pttab_child(nbdim),petab_child(nbdim), 
    19572034     &           s_parent(nbdim),s_child(nbdim), 
    1958      &           ds_parent(nbdim),ds_child(nbdim)) 
     2035     &           ds_parent(nbdim),ds_child(nbdim), 
     2036     &                  coeffraf,locind_child_left) 
    19592037C 
    19602038          enddo  
     
    20132091      REAL, DIMENSION(:,:,:,:,:), Allocatable :: tabtemp 
    20142092      INTEGER :: i,j,k,l,m 
     2093      INTEGER :: coeffraf,locind_child_left 
    20152094C 
    20162095C 
     
    20232102      do m = pttab_child(nbdim),petab_child(nbdim) 
    20242103C 
    2025         Call Agrif_Update_4D_recursive(TypeUpdate,     
     2104        Call Agrif_Update_4D_recursive(TypeUpdate(1:nbdim-1),     
    20262105     &         tabtemp(indmin(nbdim-4):indmax(nbdim-4), 
    20272106     &                 indmin(nbdim-3):indmax(nbdim-3), 
     
    20382117C 
    20392118      enddo 
     2119       
     2120      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim), 
     2121     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left) 
    20402122C 
    20412123      do l = indmin(4),indmax(4) 
     
    20542136     &           pttab_child(nbdim),petab_child(nbdim), 
    20552137     &           s_parent(nbdim),s_child(nbdim), 
    2056      &           ds_parent(nbdim),ds_child(nbdim)) 
     2138     &           ds_parent(nbdim),ds_child(nbdim), 
     2139     &                  coeffraf,locind_child_left) 
    20572140C 
    20582141            enddo 
     
    21162199      REAL, DIMENSION(:,:,:,:,:,:), Allocatable :: tabtemp 
    21172200      INTEGER :: i,j,k,l,m,n 
     2201      INTEGER :: coeffraf,locind_child_left 
    21182202C 
    21192203C 
     
    21272211      do n = pttab_child(nbdim),petab_child(nbdim) 
    21282212C 
    2129         Call Agrif_Update_5D_recursive(TypeUpdate,     
     2213        Call Agrif_Update_5D_recursive(TypeUpdate(1:nbdim-1),     
    21302214     &         tabtemp(indmin(nbdim-5):indmax(nbdim-5), 
    21312215     &                 indmin(nbdim-4):indmax(nbdim-4), 
     
    21442228C 
    21452229      enddo 
     2230       
     2231      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim), 
     2232     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left) 
    21462233C 
    21472234      do m = indmin(5),indmax(5) 
     
    21612248     &           pttab_child(nbdim),petab_child(nbdim), 
    21622249     &           s_parent(nbdim),s_child(nbdim), 
    2163      &           ds_parent(nbdim),ds_child(nbdim)) 
     2250     &           ds_parent(nbdim),ds_child(nbdim), 
     2251     &                  coeffraf,locind_child_left) 
    21642252C 
    21652253            enddo 
     
    21882276     &                            parenttab,childtab, 
    21892277     &                            indmin,indmax,pttab_child,petab_child, 
    2190      &                            s_parent,s_child,ds_parent,ds_child) 
     2278     &                            s_parent,s_child,ds_parent,ds_child, 
     2279     &                            coeffraf,locind_child_left) 
    21912280C 
    21922281CCC   Description: 
     
    22062295      REAL,DIMENSION(pttab_child:petab_child) :: childtab       
    22072296      REAL    :: s_parent,s_child 
    2208       REAL    :: ds_parent,ds_child        
     2297      REAL    :: ds_parent,ds_child       
     2298      INTEGER :: coeffraf,locind_child_left 
    22092299C 
    22102300C 
    22112301      if (TypeUpdate == AGRIF_Update_copy) then 
    22122302C              
    2213           Call copy1D 
     2303          Call agrif_copy1D 
    22142304     &       (parenttab,childtab, 
    22152305     &          indmax-indmin+1,petab_child-pttab_child+1, 
     
    22282318     &       (parenttab,childtab, 
    22292319     &          indmax-indmin+1,petab_child-pttab_child+1, 
    2230      &          s_parent,s_child,ds_parent,ds_child) 
     2320     &          s_parent,s_child,ds_parent,ds_child, 
     2321     &          coeffraf,locind_child_left) 
    22312322C 
    22322323      endif  
     
    22382329C 
    22392330C 
     2331 
     2332      Subroutine Agrif_Compute_nbdim_update(s_parent,s_child, 
     2333     &  ds_parent,ds_child,coeffraf,locind_child_left) 
     2334      real :: s_parent,s_child,ds_parent,ds_child 
     2335      integer :: coeffraf,locind_child_left 
     2336      
     2337      coeffraf = nint(ds_parent/ds_child) 
     2338      locind_child_left = 1 + agrif_int((s_parent-s_child)/ds_child) 
     2339       
     2340      End Subroutine Agrif_Compute_nbdim_update 
     2341  
     2342#if defined AGRIF_MPI       
     2343      Subroutine Agrif_Find_list_update(list_update,pttab,petab, 
     2344     &                          pttab_Child,pttab_Parent,nbdim, 
     2345     &     find_list_update,tab4t,tab5t,memberinall,memberinall2)      
     2346      TYPE(Agrif_List_Interp_Loc), Pointer :: list_update 
     2347      INTEGER :: nbdim 
     2348      INTEGER,DIMENSION(nbdim)   :: pttab,petab,pttab_Child,pttab_Parent 
     2349      LOGICAL :: find_list_update 
     2350      Type(Agrif_List_Interp_loc), Pointer :: parcours 
     2351      INTEGER :: i 
     2352C 
     2353      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,4) :: tab4t, tab5t 
     2354      LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: memberinall,memberinall2 
     2355                     
     2356      find_list_update = .FALSE. 
     2357       
     2358      parcours => list_update 
     2359       
     2360      Find_loop :   Do While (associated(parcours)) 
     2361        Do i=1,nbdim 
     2362          IF ((pttab(i) /= parcours%interp_loc%pttab(i)).OR. 
     2363     &        (petab(i) /= parcours%interp_loc%petab(i)).OR. 
     2364     &        (pttab_child(i) /= parcours%interp_loc%pttab_child(i)).OR. 
     2365     &        (pttab_parent(i) /= parcours%interp_loc%pttab_parent(i))) 
     2366     &               THEN 
     2367            parcours=>parcours%suiv 
     2368            Cycle Find_loop 
     2369          ENDIF 
     2370        EndDo 
     2371         
     2372        tab4t = parcours%interp_loc%tab4t(1:nbdim,0:Agrif_Nbprocs-1,1:4) 
     2373        memberinall = parcours%interp_loc%memberinall(0:Agrif_Nbprocs-1) 
     2374         
     2375        tab5t = parcours%interp_loc%tab5t(1:nbdim,0:Agrif_Nbprocs-1,1:4) 
     2376        memberinall2 =  
     2377     &       parcours%interp_loc%memberinall2(0:Agrif_Nbprocs-1) 
     2378         
     2379        find_list_update = .TRUE.    
     2380        Exit Find_loop 
     2381      End Do Find_loop   
     2382                               
     2383      End Subroutine Agrif_Find_list_update   
     2384       
     2385      Subroutine Agrif_AddTo_list_update(list_update,pttab,petab, 
     2386     &                          pttab_Child,pttab_Parent,nbdim 
     2387     &      ,tab4t,tab5t,memberinall,memberinall2) 
     2388           
     2389      TYPE(Agrif_List_Interp_Loc), Pointer :: list_update 
     2390      INTEGER :: nbdim 
     2391      INTEGER,DIMENSION(nbdim)   :: pttab,petab,pttab_Child,pttab_Parent 
     2392      INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,4) :: tab4t, tab5t 
     2393      LOGICAL,DIMENSION(0:Agrif_Nbprocs-1) :: memberinall, memberinall2 
     2394 
     2395      Type(Agrif_List_Interp_loc), Pointer :: parcours 
     2396             
     2397       Allocate(parcours) 
     2398      Allocate(parcours%interp_loc) 
     2399       
     2400      parcours%interp_loc%pttab(1:nbdim) = pttab(1:nbdim) 
     2401      parcours%interp_loc%petab(1:nbdim) = petab(1:nbdim) 
     2402      parcours%interp_loc%pttab_child(1:nbdim) = pttab_child(1:nbdim) 
     2403      parcours%interp_loc%pttab_parent(1:nbdim) = pttab_parent(1:nbdim) 
     2404      Allocate(parcours%interp_loc%tab4t(nbdim,0:Agrif_Nbprocs-1,4)) 
     2405      Allocate(parcours%interp_loc%memberinall(0:Agrif_Nbprocs-1)) 
     2406       
     2407      Allocate(parcours%interp_loc%tab5t(nbdim,0:Agrif_Nbprocs-1,4)) 
     2408      Allocate(parcours%interp_loc%memberinall2(0:Agrif_Nbprocs-1)) 
     2409             
     2410      parcours%interp_loc%tab4t=tab4t    
     2411      parcours%interp_loc%memberinall=memberinall 
     2412  
     2413      parcours%interp_loc%tab5t=tab5t    
     2414      parcours%interp_loc%memberinall2=memberinall2 
     2415             
     2416      parcours%suiv => list_update 
     2417       
     2418      list_update => parcours 
     2419       
     2420      End Subroutine Agrif_Addto_list_update 
     2421#endif 
     2422            
    22402423      End Module Agrif_Update 
    22412424 
    2242  
    2243  
    2244        
     2425C     ************************************************************************** 
     2426CCC   Subroutine Agrif_Update_1D_Recursive 
     2427C     ************************************************************************** 
     2428C 
     2429      Subroutine Agrif_Update_1D_recursive(TypeUpdate,tempP,tempC, 
     2430     &                                     indmin,indmax, 
     2431     &                                     pttab_child,petab_child, 
     2432     &                                     s_child,s_parent, 
     2433     &                                     ds_child,ds_parent,nbdim) 
     2434C 
     2435CCC   Description: 
     2436CCC   Subroutine to update a 1D grid variable on the parent grid. 
     2437C 
     2438CC    Method: 
     2439C 
     2440C     Declarations: 
     2441C 
     2442       
     2443C 
     2444C     Arguments 
     2445      USE Agrif_Update 
     2446      INTEGER                   :: nbdim 
     2447      INTEGER, DIMENSION(nbdim) :: TypeUpdate            ! TYPE of update (copy or average) 
     2448      INTEGER, DIMENSION(nbdim) :: indmin,indmax 
     2449      INTEGER, DIMENSION(nbdim) :: pttab_child,petab_child 
     2450      REAL, DIMENSION(nbdim)    :: s_child,s_parent 
     2451      REAL, DIMENSION(nbdim)    :: ds_child,ds_parent 
     2452      REAL, DIMENSION(indmin(nbdim):indmax(nbdim))           :: tempP 
     2453      REAL, DIMENSION(pttab_child(nbdim):petab_child(nbdim)) :: tempC 
     2454      INTEGER :: coeffraf,locind_child_left 
     2455C 
     2456C 
     2457      Call Agrif_Compute_nbdim_update(s_parent(nbdim),s_child(nbdim), 
     2458     &  ds_parent(nbdim),ds_child(nbdim),coeffraf,locind_child_left) 
     2459       
     2460      Call Agrif_UpdateBase(TypeUpdate(1), 
     2461     &                  tempP(indmin(nbdim):indmax(nbdim)), 
     2462     &                  tempC(pttab_child(nbdim):petab_child(nbdim)), 
     2463     &                  indmin(nbdim),indmax(nbdim),            
     2464     &                  pttab_child(nbdim),petab_child(nbdim), 
     2465     &                  s_parent(nbdim),s_child(nbdim), 
     2466     &                  ds_parent(nbdim),ds_child(nbdim), 
     2467     &                  coeffraf,locind_child_left) 
     2468C 
     2469      Return 
     2470C 
     2471C 
     2472      End Subroutine Agrif_Update_1D_recursive       
  • trunk/AGRIF/AGRIF_FILES/modupdatebasic.F

    r447 r662  
    4848C     **************************************************************************  
    4949C 
    50       Subroutine copy1d(x,y,np,nc, 
     50      Subroutine agrif_copy1d(x,y,np,nc, 
    5151     &                  s_parent,s_child,ds_parent,ds_child)  
    5252C 
     
    9999C 
    100100C 
    101       End Subroutine copy1d 
     101      End Subroutine agrif_copy1d 
    102102C 
    103103C 
     
    147147       
    148148      IF ( mod(coeffraf,2) == 0 ) diffmod = 1 
     149 
     150        locind_child_left = 1 + agrif_int((xpos - s_child)/ds_child) 
    149151       
    150152      do i = 1,np 
    151153C 
    152         locind_child_left = 1 + agrif_int((xpos - s_child)/ds_child) 
    153 C 
    154         if ((locind_child_left-1 < 1)  
    155      &      .OR. (locind_child_left+1 > nc)) then  
    156 C 
    157             x(i) = y(locind_child_left)                 
    158 C 
    159           else  
     154 
     155C 
     156c        if ((locind_child_left-1 < 1)  
     157c     &      .OR. (locind_child_left+1 > nc)) then  
     158C 
     159c            x(i) = y(locind_child_left)                 
     160C 
     161c          else  
    160162          nbnonnuls = 0 
    161163          Do ii = -coeffraf/2+locind_child_left+diffmod, 
     
    181183            ENDIF 
    182184C 
    183         endif 
    184 C 
    185         xpos = xpos + ds_parent 
     185c       endif 
     186C 
     187c        xpos = xpos + ds_parent 
     188        locind_child_left = locind_child_left + coeffraf 
    186189C 
    187190      enddo 
     
    199202C 
    200203      Subroutine full_weighting1D(x,y,np,nc, 
    201      &                            s_parent,s_child,ds_parent,ds_child)  
     204     &                            s_parent,s_child,ds_parent,ds_child, 
     205     &                            coeffraf,locind_child_left)  
    202206C 
    203207CCC   Description: 
     
    214218C     Local variables 
    215219      INTEGER :: i,locind_child_left,coeffraf 
    216       REAL    :: xpos  
    217 C  
    218 C 
    219       coeffraf = nint(ds_parent/ds_child) 
     220      REAL    :: xpos,sumweight,weight 
     221      INTEGER :: ii,diffmod 
     222      REAL :: xposfin 
     223      INTEGER :: it1,it2 
     224      INTEGER :: i1,i2 
     225      REAL :: invsumweight 
     226      REAL :: weights(-(coeffraf-1):coeffraf-1) 
     227       
     228C 
    220229C 
    221230      if (coeffraf == 1) then 
    222 C 
    223           locind_child_left = 1 + nint((s_parent - s_child)/ds_child) 
    224231C         
    225232          x(1:np) = y(locind_child_left:locind_child_left+np-1) 
     
    229236      endif 
    230237C 
    231       IF (coeffraf .NE. 3) THEN 
    232         print *,'FULL WEIGHTING NOT READY FOR COEFFRAF = 3' 
    233         STOP 
    234       ENDIF 
    235238      xpos = s_parent       
    236 C 
     239       
     240       x = 0. 
     241 
     242       xposfin = s_child + ds_child * (locind_child_left - 1) 
     243       IF (abs(xposfin - xpos).LT.0.001) THEN 
     244          diffmod = 0 
     245       ELSE 
     246          diffmod = 1 
     247       ENDIF 
     248C 
     249              
     250       it1 = -(coeffraf-1) 
     251       i1 = -(coeffraf-1)+locind_child_left+diffmod 
     252       i2 = 2*coeffraf - 2 
     253        
     254      invsumweight=1./coeffraf**2 
     255      do i=-(coeffraf-1),0 
     256        weights(i) = invsumweight*(coeffraf + i) 
     257      enddo 
     258      do i=1,coeffraf-1 
     259        weights(i) = invsumweight*(coeffraf - i) 
     260      enddo 
     261 
     262      sumweight = 0                     
    237263      do i = 1,np 
    238264C 
    239         locind_child_left = 1 + nint((xpos - s_child)/ds_child) 
    240 C 
    241         if ((locind_child_left-1 < 1)  
    242      &      .OR. (locind_child_left+1 > nc)) then  
    243 C      Agrif_UseSpecialValueInUpdate = .TRUE. 
    244             x(i) = y(locind_child_left)                 
    245 C 
    246           else 
    247 C         
    248             x(i) = (y(locind_child_left-1)+2.*y(locind_child_left)+ 
    249      &              y(locind_child_left+1))/4.                 
    250 C 
    251         endif 
    252 C 
    253         xpos = xpos + ds_parent 
    254 C 
    255       enddo 
     265          it2 = it1 
     266          Do ii = i1,i1+i2 
     267C 
     268           IF (Agrif_UseSpecialValueInUpdate) THEN 
     269            IF (y(ii) .NE. Agrif_SpecialValueFineGrid) THEN 
     270               x(i) = x(i) + weights(it2)*y(ii) 
     271               sumweight = sumweight+weights(it2) 
     272            ENDIF 
     273           ELSE            
     274               x(i) = x(i) + weights(it2)*y(ii) 
     275           ENDIF            
     276            
     277          it2 = it2+1 
     278          End Do 
     279 
     280           IF (Agrif_UseSpecialValueInUpdate) THEN           
     281                 IF (sumweight .NE. 0.) THEN 
     282                    x(i) = x(i)/sumweight 
     283                    sumweight = 0 
     284                 ELSE 
     285                    x(i) = Agrif_SpecialValueFineGrid 
     286                 ENDIF 
     287           ENDIF 
     288         
     289        i1 = i1 + coeffraf 
     290C 
     291      enddo     
    256292C 
    257293      Return  
    258294C             
    259295C 
    260       End Subroutine full_weighting1D       
    261 C 
    262 C 
     296      End Subroutine full_weighting1D  
     297 
    263298C 
    264299      End module AGRIF_updatebasic 
Note: See TracChangeset for help on using the changeset viewer.