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 3294 for trunk/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90 – NEMO

Ignore:
Timestamp:
2012-01-28T17:44:18+01:00 (12 years ago)
Author:
rblod
Message:

Merge of 3.4beta into the trunk

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90

    r3292 r3294  
    3838  USE dianam          ! build name of file 
    3939  USE lib_mpp         ! distributed memory computing library 
    40 #if defined key_ice_lim2 || defined key_ice_lim3 
     40#if defined key_lim2 || defined key_lim3 
    4141  USE ice 
    4242#endif 
    4343  USE domvvl 
     44  USE timing          ! preformance summary 
     45  USE wrk_nemo        ! working arrays 
    4446 
    4547  IMPLICIT NONE 
     
    114116     NAMELIST/namdct/nn_dct,nn_dctwri,nn_secdebug 
    115117 
     118     IF( nn_timing == 1 )   CALL timing_start('dia_dct_init') 
     119 
    116120     !read namelist 
    117121     REWIND( numnam ) 
     
    147151     ENDIF 
    148152 
    149  
     153     IF( nn_timing == 1 )   CALL timing_stop('dia_dct_init') 
     154     ! 
    150155  END SUBROUTINE dia_dct_init 
    151156  
     
    161166 
    162167     !! * Local variables 
    163      INTEGER             :: jsec,            &!loop on sections 
    164                             iost              !error for opening fileout 
    165      LOGICAL             :: lldebug =.FALSE.  !debug a section   
    166      CHARACTER(len=160)  :: clfileout         !fileout name 
     168     INTEGER             :: jsec,            &! loop on sections 
     169                            iost,            &! error for opening fileout 
     170                            itotal            ! nb_sec_max*nb_type_class*nb_class_max 
     171     LOGICAL             :: lldebug =.FALSE.  ! debug a section   
     172     CHARACTER(len=160)  :: clfileout         ! fileout name 
    167173 
    168174      
    169      INTEGER , DIMENSION(1):: ish                                       ! tmp array for mpp_sum 
    170      INTEGER , DIMENSION(3):: ish2                                      !   " 
    171      REAL(wp), DIMENSION(nb_sec_max*nb_type_class*nb_class_max):: zwork !   "   
    172      REAL(wp), DIMENSION(nb_sec_max,nb_type_class,nb_class_max):: zsum  !   " 
     175     INTEGER , DIMENSION(1)             :: ish   ! tmp array for mpp_sum 
     176     INTEGER , DIMENSION(3)             :: ish2  !   " 
     177     REAL(wp), POINTER, DIMENSION(:)    :: zwork !   "   
     178     REAL(wp), POINTER, DIMENSION(:,:,:):: zsum  !   " 
    173179 
    174180     !!---------------------------------------------------------------------     
    175  
     181     IF( nn_timing == 1 )   CALL timing_start('dia_dct') 
     182 
     183     IF( lk_mpp )THEN 
     184        itotal = nb_sec_max*nb_type_class*nb_class_max 
     185        CALL wrk_alloc( itotal                                , zwork )  
     186        CALL wrk_alloc( nb_sec_max,nb_type_class,nb_class_max , zsum  ) 
     187     ENDIF     
     188  
    176189     IF( lwp .AND. kt==nit000+nn_dct-1 ) THEN 
    177190         WRITE(numout,*) " " 
     
    189202           !debug this section computing ? 
    190203           lldebug=.FALSE. 
    191 !           IF( (jsec==nn_secdebug .OR. nn_secdebug==-1) .AND.  kt==nit000+nn_dct-1 .AND. lwp ) lldebug=.TRUE.  
    192            IF( (jsec==nn_secdebug .OR. nn_secdebug==-1) .AND.  kt==nit000+nn_dct-1 ) lldebug=.TRUE.  
     204           IF( (jsec==nn_secdebug .OR. nn_secdebug==-1) .AND.  kt==nit000+nn_dct-1 .AND. lwp ) lldebug=.TRUE.  
    193205 
    194206           !Compute transport through section   
     
    226238     ENDIF 
    227239 
     240     IF( lk_mpp )THEN 
     241        itotal = nb_sec_max*nb_type_class*nb_class_max 
     242        CALL wrk_dealloc( itotal                                , zwork )  
     243        CALL wrk_dealloc( nb_sec_max,nb_type_class,nb_class_max , zsum  ) 
     244     ENDIF     
     245 
     246     IF( nn_timing == 1 )   CALL timing_stop('dia_dct') 
     247     ! 
    228248  END SUBROUTINE dia_dct 
    229249 
     
    250270     TYPE(POINT_SECTION),DIMENSION(nb_point_max)  ::coordtemp !contains listpoints coordinates  
    251271                                                              !read in the file 
    252      INTEGER,DIMENSION(nb_point_max)  ::directemp             !contains listpoints directions 
     272     INTEGER, POINTER, DIMENSION(:) :: directemp              !contains listpoints directions 
    253273                                                              !read in the files 
    254274     LOGICAL :: llbon                                       ,&!local logical 
    255275                lldebug                                       !debug the section 
    256276     !!------------------------------------------------------------------------------------- 
     277     CALL wrk_alloc( nb_point_max, directemp ) 
    257278 
    258279     !open input file 
     
    381402           ENDIF 
    382403 
     404              IF(jsec==nn_secdebug .AND. secs(jsec)%nb_point .NE. 0)THEN 
     405              WRITE(narea+200,*)'avant secs(jsec)%nb_point iptloc ',secs(jsec)%nb_point,iptloc 
     406              DO jpt = 1,iptloc 
     407                 iiglo = secs(jsec)%listPoint(jpt)%I + jpizoom - 1 + nimpp - 1 
     408                 ijglo = secs(jsec)%listPoint(jpt)%J + jpjzoom - 1 + njmpp - 1 
     409                 WRITE(narea+200,*)'avant # I J : ',iiglo,ijglo 
     410              ENDDO 
     411              ENDIF 
     412 
    383413           !remove redundant points between processors 
    384414           !------------------------------------------ 
     
    390420              CALL removepoints(secs(jsec),'J','bot_list',lldebug) 
    391421           ENDIF 
     422           IF(jsec==nn_secdebug .AND. secs(jsec)%nb_point .NE. 0)THEN 
     423              WRITE(narea+200,*)'apres secs(jsec)%nb_point iptloc ',secs(jsec)%nb_point,iptloc 
     424              DO jpt = 1,secs(jsec)%nb_point 
     425                 iiglo = secs(jsec)%listPoint(jpt)%I + jpizoom - 1 + nimpp - 1 
     426                 ijglo = secs(jsec)%listPoint(jpt)%J + jpjzoom - 1 + njmpp - 1 
     427                 WRITE(narea+200,*)'apres # I J : ',iiglo,ijglo 
     428              ENDDO 
     429           ENDIF 
    392430 
    393431           !debug 
     
    395433           IF( lwp .AND. ( jsec==nn_secdebug .OR. nn_secdebug==-1 ) )THEN 
    396434              WRITE(numout,*)"      List of points after removepoints:" 
     435              iptloc = secs(jsec)%nb_point 
    397436              DO jpt = 1,iptloc 
    398437                 iiglo = secs(jsec)%listPoint(jpt)%I + jpizoom - 1 + nimpp - 1 
     
    411450     nb_sec = jsec-1   !number of section read in the file 
    412451 
     452     CALL wrk_dealloc( nb_point_max, directemp ) 
     453     ! 
    413454  END SUBROUTINE readsec 
    414455 
     
    436477                                 ! isgn=-1 : scan listpoint from end to start  
    437478                istart,iend      !first and last points selected in listpoint 
    438      INTEGER :: jpoint   =0      !loop on list points 
    439      INTEGER,DIMENSION(nb_point_max)   :: idirec !contains temporary sec%direction 
    440      INTEGER,DIMENSION(2,nb_point_max) :: icoord !contains temporary sec%listpoint 
     479     INTEGER :: jpoint           !loop on list points 
     480     INTEGER, POINTER, DIMENSION(:)   :: idirec !contains temporary sec%direction 
     481     INTEGER, POINTER, DIMENSION(:,:) :: icoord !contains temporary sec%listpoint 
    441482     !---------------------------------------------------------------------------- 
     483     CALL wrk_alloc(    nb_point_max, idirec ) 
     484     CALL wrk_alloc( 2, nb_point_max, icoord ) 
     485 
    442486     IF( ld_debug )WRITE(numout,*)'      -------------------------' 
    443487     IF( ld_debug )WRITE(numout,*)'      removepoints in listpoint' 
     
    467511     sec%direction            = 0 
    468512 
    469  
    470513     jpoint=iextr+isgn 
    471      DO WHILE( jpoint .GE. 1 .AND. jpoint .LE. sec%nb_point  .AND. & 
    472         icoord( iind,jpoint-isgn ) == itest .AND. icoord( iind,jpoint ) == itest ) 
    473         jpoint=jpoint+isgn 
    474      ENDDO 
     514     DO WHILE( jpoint .GE. 1 .AND. jpoint .LE. sec%nb_point ) 
     515         IF( icoord( iind,jpoint-isgn ) == itest .AND. icoord( iind,jpoint ) == itest )THEN ; jpoint=jpoint+isgn 
     516         ELSE                                                                               ; EXIT 
     517         ENDIF 
     518     ENDDO  
    475519 
    476520     IF( cdextr=='bot_list')THEN ; istart=jpoint-1 ; iend=sec%nb_point 
    477521     ELSE                        ; istart=1        ; iend=jpoint+1 
    478522     ENDIF 
     523 
    479524     sec%listPoint(1:1+iend-istart)%I = icoord(1,istart:iend) 
    480525     sec%listPoint(1:1+iend-istart)%J = icoord(2,istart:iend) 
     
    487532     ENDIF 
    488533 
     534     CALL wrk_dealloc(    nb_point_max, idirec ) 
     535     CALL wrk_dealloc( 2, nb_point_max, icoord ) 
    489536  END SUBROUTINE removepoints 
    490537 
     
    536583 
    537584     TYPE(POINT_SECTION) :: k 
    538      REAL(wp),DIMENSION(nb_type_class,nb_class_max)::zsum 
     585     REAL(wp), POINTER, DIMENSION(:,:):: zsum ! 2D work array 
    539586     !!-------------------------------------------------------- 
     587     CALL wrk_alloc( nb_type_class , nb_class_max , zsum   ) 
    540588 
    541589     IF( ld_debug )WRITE(numout,*)'      Compute transport' 
     
    746794           ENDDO !end of loop on the density classes 
    747795 
    748 #if defined key_ice_lim 
     796#if defined key_lim2 || defined key_lim3 
    749797 
    750798           !ICE CASE     
     
    812860        sec%transport(2,jclass)=sec%transport(2,jclass)+zsum(2,jclass)*1.E-6 
    813861        IF( sec%llstrpond ) THEN 
    814            IF( zsum(1,jclass) .NE. 0 ) THEN 
    815               sec%transport(3,jclass)=sec%transport(3,jclass)+zsum(3,jclass)/zsum(1,jclass) 
    816               sec%transport(5,jclass)=sec%transport(5,jclass)+zsum(5,jclass)/zsum(1,jclass) 
    817               sec%transport(7,jclass)=sec%transport(7,jclass)+zsum(7,jclass) 
    818               sec%transport(9,jclass)=sec%transport(9,jclass)+zsum(9,jclass) 
    819            ELSE 
    820               sec%transport(3,jclass)=0. 
    821               sec%transport(5,jclass)=0. 
    822               sec%transport(7,jclass)=0. 
    823               sec%transport(9,jclass)=0. 
     862           IF( zsum(1,jclass) .NE. 0._wp ) THEN 
     863              sec%transport( 3,jclass) = sec%transport( 3,jclass) + zsum( 3,jclass)/zsum(1,jclass) 
     864              sec%transport( 5,jclass) = sec%transport( 5,jclass) + zsum( 5,jclass)/zsum(1,jclass) 
     865              sec%transport( 7,jclass) = sec%transport( 7,jclass) + zsum( 7,jclass) 
     866              sec%transport( 9,jclass) = sec%transport( 9,jclass) + zsum( 9,jclass) 
    824867           ENDIF 
    825            IF( zsum(2,jclass) .NE. 0 )THEN 
    826               sec%transport( 4,jclass)=sec%transport( 4,jclass)+zsum( 4,jclass)/zsum(2,jclass) 
    827               sec%transport( 6,jclass)=sec%transport( 6,jclass)+zsum( 6,jclass)/zsum(2,jclass) 
    828               sec%transport( 8,jclass)=sec%transport( 8,jclass)+zsum( 8,jclass) 
    829               sec%transport(10,jclass)=sec%transport(10,jclass)+zsum(10,jclass) 
    830            ELSE 
    831               sec%transport( 4,jclass)=0. 
    832               sec%transport( 6,jclass)=0. 
    833               sec%transport( 8,jclass)=0. 
    834               sec%transport(10,jclass)=0. 
     868           IF( zsum(2,jclass) .NE. 0._wp )THEN 
     869              sec%transport( 4,jclass) = sec%transport( 4,jclass) + zsum( 4,jclass)/zsum(2,jclass) 
     870              sec%transport( 6,jclass) = sec%transport( 6,jclass) + zsum( 6,jclass)/zsum(2,jclass) 
     871              sec%transport( 8,jclass) = sec%transport( 8,jclass) + zsum( 8,jclass) 
     872              sec%transport(10,jclass) = sec%transport(10,jclass) + zsum(10,jclass) 
    835873           ENDIF 
    836874        ELSE 
    837            sec%transport( 3,jclass)=0. 
    838            sec%transport( 4,jclass)=0. 
    839            sec%transport( 5,jclass)=0. 
    840            sec%transport( 6,jclass)=0. 
    841            sec%transport( 7,jclass)=0. 
    842            sec%transport( 8,jclass)=0. 
    843            sec%transport(10,jclass)=0. 
     875           sec%transport( 3,jclass) = 0._wp 
     876           sec%transport( 4,jclass) = 0._wp 
     877           sec%transport( 5,jclass) = 0._wp 
     878           sec%transport( 6,jclass) = 0._wp 
     879           sec%transport( 7,jclass) = 0._wp 
     880           sec%transport( 8,jclass) = 0._wp 
     881           sec%transport(10,jclass) = 0._wp 
    844882        ENDIF 
    845883     ENDDO    
     
    852890     ENDIF 
    853891 
     892     CALL wrk_dealloc( nb_type_class , nb_class_max , zsum   ) 
     893     ! 
    854894  END SUBROUTINE transport 
    855895   
     
    872912     !!-------------------------------------------------------------  
    873913     !!arguments 
    874      INTEGER, INTENT(IN)          :: kt         ! time-step 
    875      TYPE(SECTION), INTENT(INOUT) :: sec        ! section to write    
    876      INTEGER ,INTENT(IN)          :: ksec       ! section number 
     914     INTEGER, INTENT(IN)          :: kt          ! time-step 
     915     TYPE(SECTION), INTENT(INOUT) :: sec         ! section to write    
     916     INTEGER ,INTENT(IN)          :: ksec        ! section number 
    877917 
    878918     !!local declarations 
    879      REAL(wp) ,DIMENSION(nb_type_class):: zsumclass 
    880      INTEGER               :: jcl,ji            ! Dummy loop 
    881      CHARACTER(len=2)      :: classe            ! Classname  
    882      REAL(wp)              :: zbnd1,zbnd2       ! Class bounds 
    883      REAL(wp)              :: zslope            ! section's slope coeff 
     919     INTEGER               :: jcl,ji             ! Dummy loop 
     920     CHARACTER(len=2)      :: classe             ! Classname  
     921     REAL(wp)              :: zbnd1,zbnd2        ! Class bounds 
     922     REAL(wp)              :: zslope             ! section's slope coeff 
     923     ! 
     924     REAL(wp), POINTER, DIMENSION(:):: zsumclass ! 1D workspace  
    884925     !!-------------------------------------------------------------  
    885        
     926     CALL wrk_alloc(nb_type_class , zsumclass )   
     927 
    886928     zsumclass(:)=0._wp 
    887929     zslope = sec%slopeSection        
     
    9961038119 FORMAT(I8,1X,I8,1X,I4,1X,A30,1X,f9.2,1X,I4,3X,A8,1X,2F12.4,5X,3E15.6) 
    9971039 
     1040     CALL wrk_dealloc(nb_type_class , zsumclass )   
    9981041  END SUBROUTINE dia_dct_wri 
    9991042 
Note: See TracChangeset for help on using the changeset viewer.