Opened 3 years ago

Closed 17 months ago

#1870 closed Bug (fixed)

NESTING TOOLS AGRIF create restart files

Reported by: jharlass Owned by: sciliberti
Priority: normal Milestone:
Component: AGRIF Version: release-3.6
Severity: major Keywords: AGRIF Tools nesting restartability
Cc: sciliberti

Description (last modified by nicolasmartin)

Context

AGRIF NESTING TOOLS: agrif_create_restart.exe does not work with current NEMO 3.6 version

Analysis

Create restart file for AGRIF NEST from base model restart (global file).

  1. Restart variables of current NEMO version were unknown to nesting tools.
  2. The nest grid can have deeper values than the base grid, if e.g. bathymetry created with ETOPO. Happens in the near bottom levels in ragged bathymetry. Since there are no vlaues to inter/extrapolate they remain zero which causes the model to crash after a few time steps as e.g. zero salinity causes huge gradients, creating instabilty and so on …

Fix

  1. Add all variables needed.
  2. New routine ("check_interpextrap") that checks for such missing values and replaces them with values from 1 level above.

CHANGES IN: NESTING/src/agrif_create_restart.f90:

  • (a) Revision vs. (b) Working

    a b  
    436458        ENDIF 
    437459        ! 
    438460        ! Variable interpolation according to their position on grid 
    439         !                                    
    440      CASE('un','ub')   
     461        ! 
     462        ! grid U 
     463        ! 3D  
     464     CASE('un','ub','avu','avmu')   
     465        ! irec only for DIMG format ! 
    441466        varname = Ncdf_varname(i) 
    442  
    443467        IF(TRIM(varname)=='un') irec = 6 * z + 2 
    444468        IF(TRIM(varname)=='ub') irec = 2 
    445  
    446         WRITE(*,*) TRIM(varname),'interpolation ...'     
     469!        WRITE(*,*) TRIM(varname),'interpolation ...'     
    447470        vert_coord_name = 'z'              
    448471        posvar='U' 
    449472        Interpolation = .TRUE.   
    450         ! 
    451      CASE('u_io' 
     473        ! 1D                                   
     474     CASE('u_io','ssu_m','utau_b') 
    452475        varname = Ncdf_varname(i)   
    453         WRITE(*,*) TRIM(varname),'interpolation ...'     
     476!        WRITE(*,*) TRIM(varname),'interpolation ...'     
    454477        vert_coord_name = 'z_b'              
    455478        posvar='U' 
    456479        Interpolation = .TRUE.  
    457         !                           
    458      CASE('vn','vb') 
     480        ! 
     481        ! grid V 
     482        ! 3D 
     483     CASE('vn','vb','avmv') 
    459484        varname = Ncdf_varname(i) 
    460  
    461485        IF(TRIM(varname)=='vn') irec = 7 * z + 2 
    462486        IF(TRIM(varname)=='vb') irec = 2 + z 
    463  
    464         WRITE(*,*) TRIM(varname),'interpolation ...'       
     487!        WRITE(*,*) TRIM(varname),'interpolation ...'       
    465488        vert_coord_name = 'z' 
    466489        posvar='V' 
    467490        Interpolation = .TRUE.      
    468         !               
    469      CASE('v_io') 
     491        ! 1D              
     492     CASE('v_io','ssv_m','vtau_b') 
    470493        varname = Ncdf_varname(i) 
    471         WRITE(*,*) TRIM(varname),'interpolation ...'       
     494!        WRITE(*,*) TRIM(varname),' interpolation ...'       
    472495        vert_coord_name = 'z_b' 
    473496        posvar='V' 
    474497        Interpolation = .TRUE. 
    475         !              
    476      CASE('gcx','gcxb','sshb','sshn','sst_io','sss_io','gsst') 
    477         varname = Ncdf_varname(i)     
    478  
    479         IF(TRIM(varname)=='gcx') irec = 12 * z + 2 
    480         IF(TRIM(varname)=='gcxb')  irec = 12 * z + 3 
    481         IF(TRIM(varname)=='sshb') irec = 12 * z + 4 
    482         IF(TRIM(varname)=='sshn') irec = 12 * z + 5 
    483  
    484         WRITE(*,*) TRIM(varname),'interpolation ...'  
    485         vert_coord_name = 'z_b'              
    486         posvar='T' 
    487         Interpolation = .TRUE.      
    488  
    489         !   
    490      CASE ('tb','sb','sn','tn') 
     498        ! 
     499        ! grid T 
     500        ! 3D 
     501     CASE ('tb','sb','tn','sn','en','avt','avm','dissl','rhop','qsr_hc_b') 
    491502        varname = Ncdf_varname(i)  
    492  
    493503        IF(TRIM(varname)=='sn') irec = 9 * z + 2 
    494504        IF(TRIM(varname)=='tn') irec = 8 * z + 2 
    495505        IF(TRIM(varname)=='sb') irec = 3 * z + 2 
    496506        IF(TRIM(varname)=='tb') irec = 2 * z + 2 
    497  
    498         WRITE(*,*) TRIM(varname),'interpolation ...'      
     507        IF(TRIM(varname)=='tb') irec = 2 * z + 2 
     508        IF(TRIM(varname)=='en') irec = 12* z + 6 
     509 !       WRITE(*,*) TRIM(varname),' interpolation ...'      
    499510        vert_coord_name = 'z' 
    500511        posvar='T' 
    501512        Interpolation = .TRUE.             
    502  
    503      CASE('en') 
    504         varname = Ncdf_varname(i)  
    505         irec = 12 * z + 6 
    506         WRITE(*,*) TRIM(varname),'interpolation ...'      
    507         vert_coord_name = 'z' 
     513        ! 1D 
     514     CASE('gcx','gcxb','sshb','sshn','sst_io','sss_io','gsst','sss_m','sst_m','ssh_m','frq_m','qns_b','emp_b','sfx_b','sbc_hc_b','sbc_sc_b','fraqsr_1lev') 
     515        varname = Ncdf_varname(i)     
     516        IF(TRIM(varname)=='gcx')  irec = 12 * z + 2 
     517        IF(TRIM(varname)=='gcxb') irec = 12 * z + 3 
     518        IF(TRIM(varname)=='sshb') irec = 12 * z + 4 
     519        IF(TRIM(varname)=='sshn') irec = 12 * z + 5 
     520 !       WRITE(*,*) TRIM(varname),' interpolation ...'  
     521        vert_coord_name = 'z_b'              
    508522        posvar='T' 
    509         Interpolation = .TRUE.              
    510  
     523        Interpolation = .TRUE.      
     524        ! 
     525        ! NO interpolation 
     526        ! 
    511527     CASE ('rotb','rotn','hdivb','hdivn') 
    512528        Interpolation = .FALSE. 
    513529        ! 

FULL COURCE CODE ATTACHED:

NESTING/src/agrif_create_restart.f90
and
NESTING/src/agrif_extrapolation.f90 with new routine: "check_interpextrap"

Commit History (0)

(No commits)

Attachments (4)

agrif_extrapolation.f90 (21.6 KB) - added by jharlass 3 years ago.
routine checking for missing values: check_interpextrap
agrif_extrapolation_allocfix.patch (842 bytes) - added by mdunphy 3 years ago.
Fix for the allocations in check_interpextrap(). This patch is for agrif_extrapolation.f90 attached to this ticket (#1870), not for the version under SVN.
agrif_create_restart.f90 (33.5 KB) - added by jharlass 2 years ago.
Clean up code, cover case of unknown variable
agrif_extrapolation.2.f90 (21.7 KB) - added by jharlass 2 years ago.
Includes patch, replace only subsurface levels

Download all attachments as: .zip

Change History (19)

Changed 3 years ago by jharlass

routine checking for missing values: check_interpextrap

comment:1 Changed 3 years ago by nemo

  • Keywords CREATE removed

comment:2 Changed 3 years ago by nemo

  • Keywords nesting added; NESTING removed

comment:3 Changed 3 years ago by nemo

  • Keywords restart added; RESTART removed

comment:4 Changed 3 years ago by nemo

  • Keywords tools added; TOOLS removed

comment:5 Changed 3 years ago by mdunphy

Hi Jan,

Thanks for this, it eliminates a bunch of post-processing work to fix up the partial steps. There's a typo in the allocations in check_interpextrap (see attached patch), but otherwise it looks good!

Changed 3 years ago by mdunphy

Fix for the allocations in check_interpextrap(). This patch is for agrif_extrapolation.f90 attached to this ticket (#1870), not for the version under SVN.

comment:6 Changed 3 years ago by clevy

  • Owner changed from nemo to sciliberti

comment:7 Changed 3 years ago by nicolasmartin

  • Description modified (diff)

comment:8 Changed 3 years ago by clevy

  • Cc sciliberti added
  • Status changed from new to assigned

comment:9 Changed 3 years ago by clevy

  • Priority changed from critical to major

comment:10 Changed 3 years ago by nemo

  • Keywords Tools added; tools removed

comment:11 Changed 3 years ago by nemo

  • Keywords restartability added; restart removed

comment:12 Changed 3 years ago by nemo

  • Keywords release-3.6* added

comment:13 Changed 3 years ago by nemo

  • Keywords release-3.6* removed

Changed 2 years ago by jharlass

Clean up code, cover case of unknown variable

Changed 2 years ago by jharlass

Includes patch, replace only subsurface levels

comment:14 Changed 2 years ago by jharlass

  • Severity set to major

I uploaded the recent version for agrif_create_restart.f90 and the new checking routine in agrif_extrapolation.2.f90​, which now is only called for 3d variables and replaces only (if necessary) below level 2. nn_fsbc has been added to the agrif restart files and the case of unknown variables is covered. Thereby we also encountered a conversion error affecting qsr_hc_b, with values of 2.E-5 and smaller. To overcome automatic conversion in netcdf we deallcoate/allocate read4d real variable every time. According changes:

  • io_netcdf.f90

     
    13371337    IF(.NOT. ASSOCIATED(tabvar)) THEN 
    13381338       ALLOCATE(tabvar(dim1,dim2,1,1))   
    13391339    ELSE 
    1340        IF ((SIZE(tabvar,1) /= dim1) .OR. (SIZE(tabvar,2) /= dim2)) THEN 
     1340      ! cjh IF ((SIZE(tabvar,1) /= dim1) .OR. (SIZE(tabvar,2) /= dim2)) THEN  
     1341      ! the only way I came up with to avoid Type Conversion! 
    13411342          DEALLOCATE(tabvar) 
    13421343          ALLOCATE(tabvar(dim1,dim2,1,1)) 
    1343       ENDIF 
     1344      ! cjh ENDIF 
    13441345    ENDIF 
    13451346    ! 
    13461347    status=nf90_get_var(ncid,varid,tabvar,start=(/1,1,level,time/),count=(/dim1,dim2,1,1/)) 
    13471348    !                                              
    13481349    IF (status/=nf90_noerr) THEN     
    13491350       WRITE(*,*)"unable to retrieve netcdf variable : ",TRIM(varname) 

comment:15 Changed 17 months ago by jchanut

  • Resolution set to fixed
  • Status changed from assigned to closed

Use the very last NESTING tool version (no correction made to the one provided with NEMO 3.6_STABLE)

Note: See TracTickets for help on using tickets.