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 15704 – NEMO

Changeset 15704


Ignore:
Timestamp:
2022-02-17T09:06:50+01:00 (2 years ago)
Author:
jenniewaters
Message:

Fix where statements in bias code to remove memory bug.

Location:
NEMO/branches/UKMO/NEMO_4.0.4_FOAM_pcbias/src/OCE
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/UKMO/NEMO_4.0.4_FOAM_pcbias/src/OCE/ASM/bias.F90

    r15602 r15704  
    5959   !!   bias_opn   : open bias files for restart capabilities 
    6060   !!   bias_wrt   : write bias fies "     "          " 
     61   !!   bias_deallocate : deallocate variables 
    6162   !!---------------------------------------------------------------------- 
    6263   !! * Modules used 
     
    108109      &   dyn_bias,    &   !: " density correction for pressure gradient. 
    109110      &   bias_opn,    & 
    110       &   bias_wrt 
     111      &   bias_wrt,    & 
     112      &   bias_deallocate 
    111113 
    112114   !! * Shared variables 
     
    516518         ! Use the inertial ramp. 
    517519         lenscl_bias = ( rn_maxlat_bias - rn_minlat_bias )*2._wp 
     520    fbcoef(:,:) = 1._wp - exp( -( abs( gphit(:,:) ) - rn_minlat_bias ) & 
     521                       * ( abs( gphit(:,:) ) - rn_minlat_bias ) / lenscl_bias )    
    518522         WHERE ( abs( gphit(:,:) ) <= rn_minlat_bias )          
    519523            fbcoef(:,:) = 0._wp           
    520          ELSEWHERE ( abs( gphit(:,:) ) >= rn_maxlat_bias )          
    521             fbcoef(:,:) = 1._wp                     
    522          ELSEWHERE         
    523             fbcoef(:,:) = 1._wp - exp( -( abs( gphit(:,:) ) - rn_minlat_bias ) & 
    524                            * ( abs( gphit(:,:) ) - rn_minlat_bias ) / lenscl_bias )                          
     524         ENDWHERE  
     525         WHERE ( abs( gphit(:,:) ) >= rn_maxlat_bias )          
     526            fbcoef(:,:) = 1._wp                                          
    525527         ENDWHERE  
    526528      ELSEIF ( nn_lat_ramp == 2 ) THEN    
    527529         ! Use a linear ramp consist with the geostrophic velocity balance ramp in NEMOVAR 
    528       
     530         fbcoef(:,:) = 1._wp - ((rn_maxlat_bias - abs( gphit(:,:)))/(rn_maxlat_bias - rn_minlat_bias)) 
    529531         WHERE ( abs( gphit(:,:) ) <= rn_minlat_bias ) 
    530532            fbcoef(:,:) = 0._wp 
    531          ELSEWHERE ( abs( gphit(:,:) ) >= rn_maxlat_bias )  
     533         ENDWHERE 
     534         WHERE ( abs( gphit(:,:) ) >= rn_maxlat_bias )  
    532535            fbcoef(:,:) = 1._wp 
    533          ELSEWHERE 
    534             fbcoef(:,:) = 1._wp - ((rn_maxlat_bias - abs( gphit(:,:)))/(rn_maxlat_bias - rn_minlat_bias)) 
    535536         ENDWHERE 
    536537      ELSE 
     
    544545         minlat_bias = 3.0_wp 
    545546         maxlat_bias = 8.0_wp   
     547         fbcoef_stscale(:,:)=1._wp - ((maxlat_bias - abs( gphit(:,:)))/(maxlat_bias-minlat_bias)) 
    546548         WHERE ( abs( gphit(:,:) ) <= minlat_bias ) 
    547549            fbcoef_stscale(:,:)=0._wp 
    548          ELSEWHERE ( abs( gphit(:,:) ) >= maxlat_bias )  
     550         ENDWHERE  
     551         WHERE ( abs( gphit(:,:) ) >= maxlat_bias )  
    549552            fbcoef_stscale(:,:)=1._wp 
    550          ELSEWHERE 
    551             fbcoef_stscale(:,:)=1._wp - ((maxlat_bias - abs( gphit(:,:)))/(maxlat_bias-minlat_bias)) 
    552553         ENDWHERE    
    553554      ENDIF  
     
    10111012   END SUBROUTINE bias_wrt 
    10121013 
     1014 
     1015   SUBROUTINE bias_deallocate 
     1016      !!--------------------------------------------------------------------- 
     1017      !!                   ***  ROUTINE bias_deallocate  *** 
     1018      !!                      
     1019      !! ** Purpose :   Deallocate bias fields 
     1020      !! 
     1021      !! 
     1022      !!---------------------------------------------------------------------- 
     1023      !!---------------------------------------------------------------------- 
     1024      ! 
     1025      IF ( ALLOCATED( tbias ) ) DEALLOCATE( tbias ) 
     1026      IF ( ALLOCATED( sbias ) ) DEALLOCATE( sbias ) 
     1027      IF ( ALLOCATED( tbias_p ) ) DEALLOCATE( tbias_p ) 
     1028      IF ( ALLOCATED( sbias_p ) ) DEALLOCATE( sbias_p ) 
     1029      IF ( ALLOCATED( tbias_i ) ) DEALLOCATE( tbias_i ) 
     1030      IF ( ALLOCATED( sbias_i ) ) DEALLOCATE( sbias_i ) 
     1031      IF ( ALLOCATED( rhd_pc ) ) DEALLOCATE( rhd_pc ) 
     1032      IF ( ALLOCATED( fbcoef ) ) DEALLOCATE( fbcoef ) 
     1033      IF ( ALLOCATED( fbcoef_stscale ) ) DEALLOCATE( fbcoef_stscale ) 
     1034      IF ( ALLOCATED( tbias_asm ) ) DEALLOCATE( tbias_asm ) 
     1035      IF ( ALLOCATED( sbias_asm ) ) DEALLOCATE( sbias_asm ) 
     1036      IF ( ALLOCATED( tbias_asm_out ) ) DEALLOCATE( tbias_asm_out ) 
     1037      IF ( ALLOCATED( sbias_asm_out ) ) DEALLOCATE( sbias_asm_out ) 
     1038      IF ( ALLOCATED( tbias_p_out ) ) DEALLOCATE( tbias_p_out ) 
     1039      IF ( ALLOCATED( sbias_p_out ) ) DEALLOCATE( sbias_p_out ) 
     1040      IF ( ALLOCATED( tbias_rlx ) ) DEALLOCATE( tbias_rlx ) 
     1041      IF ( ALLOCATED( sbias_rlx ) ) DEALLOCATE( sbias_rlx ) 
     1042      IF ( ALLOCATED( tbias_rlx_out ) ) DEALLOCATE( tbias_rlx_out ) 
     1043      IF ( ALLOCATED( sbias_rlx_out ) ) DEALLOCATE( sbias_rlx_out ) 
     1044      IF ( ALLOCATED( tbias_asm_stscale ) ) DEALLOCATE( tbias_asm_stscale ) 
     1045      IF ( ALLOCATED( sbias_asm_stscale ) ) DEALLOCATE( sbias_asm_stscale ) 
     1046      IF ( ALLOCATED( tbias_asm_stscale_out ) ) DEALLOCATE( tbias_asm_stscale_out ) 
     1047      IF ( ALLOCATED( sbias_asm_stscale_out ) ) DEALLOCATE( sbias_asm_stscale_out ) 
     1048      IF ( ALLOCATED( tbias_i_out ) ) DEALLOCATE( tbias_i_out ) 
     1049      IF ( ALLOCATED( sbias_i_out ) ) DEALLOCATE( sbias_i_out ) 
     1050      IF ( ALLOCATED( sf_tbias_ofl ) ) DEALLOCATE( sf_tbias_ofl ) 
     1051      IF ( ALLOCATED( sf_sbias_ofl ) ) DEALLOCATE( sf_sbias_ofl ) 
     1052      ! 
     1053   END SUBROUTINE bias_deallocate 
     1054 
    10131055END MODULE bias 
  • NEMO/branches/UKMO/NEMO_4.0.4_FOAM_pcbias/src/OCE/nemogcm.F90

    r15359 r15704  
    215215      ! 
    216216      IF( ln_icebergs )   CALL icb_end( nitend ) 
    217  
     217      ! 
     218      IF( lk_asminc    )  CALL bias_deallocate 
     219      ! 
    218220      !                            !------------------------! 
    219221      !                            !==  finalize the run  ==! 
Note: See TracChangeset for help on using the changeset viewer.