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.
#1870 (NESTING TOOLS AGRIF create restart files) – NEMO

Opened 7 years ago

Last modified 2 years ago

#1870 closed Bug

NESTING TOOLS AGRIF create restart files — at Initial Version

Reported by: jharlass Owned by: nemo
Priority: normal Milestone:
Component: AGRIF Version: v3.6
Severity: major Keywords: AGRIF Tools nesting restartability v3.6
Cc: sciliberti

Description

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:

--- Revision 7752
+++ Working Copy

@@ -436,78 +458,72 @@
         ENDIF
         !
         ! Variable interpolation according to their position on grid
-        !                                   
-     CASE('un','ub')  
+        !
+        ! grid U
+        ! 3D 
+     CASE('un','ub','avu','avmu')  
+        ! irec only for DIMG format !
         varname = Ncdf_varname(i)
-
         IF(TRIM(varname)=='un') irec = 6 * z + 2
         IF(TRIM(varname)=='ub') irec = 2
-
-        WRITE(*,*) TRIM(varname),'interpolation ...'    
+!        WRITE(*,*) TRIM(varname),'interpolation ...'    
         vert_coord_name = 'z'             
         posvar='U'
         Interpolation = .TRUE.  
-        !
-     CASE('u_io')  
+        ! 1D                                  
+     CASE('u_io','ssu_m','utau_b')
         varname = Ncdf_varname(i)  
-        WRITE(*,*) TRIM(varname),'interpolation ...'    
+!        WRITE(*,*) TRIM(varname),'interpolation ...'    
         vert_coord_name = 'z_b'             
         posvar='U'
         Interpolation = .TRUE. 
-        !                          
-     CASE('vn','vb')
+        !
+        ! grid V
+        ! 3D
+     CASE('vn','vb','avmv')
         varname = Ncdf_varname(i)
-
         IF(TRIM(varname)=='vn') irec = 7 * z + 2
         IF(TRIM(varname)=='vb') irec = 2 + z
-
-        WRITE(*,*) TRIM(varname),'interpolation ...'      
+!        WRITE(*,*) TRIM(varname),'interpolation ...'      
         vert_coord_name = 'z'
         posvar='V'
         Interpolation = .TRUE.     
-        !              
-     CASE('v_io')
+        ! 1D             
+     CASE('v_io','ssv_m','vtau_b')
         varname = Ncdf_varname(i)
-        WRITE(*,*) TRIM(varname),'interpolation ...'      
+!        WRITE(*,*) TRIM(varname),' interpolation ...'      
         vert_coord_name = 'z_b'
         posvar='V'
         Interpolation = .TRUE.
-        !             
-     CASE('gcx','gcxb','sshb','sshn','sst_io','sss_io','gsst')
-        varname = Ncdf_varname(i)    
-
-        IF(TRIM(varname)=='gcx') irec = 12 * z + 2
-        IF(TRIM(varname)=='gcxb')  irec = 12 * z + 3
-        IF(TRIM(varname)=='sshb') irec = 12 * z + 4
-        IF(TRIM(varname)=='sshn') irec = 12 * z + 5
-
-        WRITE(*,*) TRIM(varname),'interpolation ...' 
-        vert_coord_name = 'z_b'             
-        posvar='T'
-        Interpolation = .TRUE.     
-
-        !  
-     CASE ('tb','sb','sn','tn')
+        !
+        ! grid T
+        ! 3D
+     CASE ('tb','sb','tn','sn','en','avt','avm','dissl','rhop','qsr_hc_b')
         varname = Ncdf_varname(i) 
-
         IF(TRIM(varname)=='sn') irec = 9 * z + 2
         IF(TRIM(varname)=='tn') irec = 8 * z + 2
         IF(TRIM(varname)=='sb') irec = 3 * z + 2
         IF(TRIM(varname)=='tb') irec = 2 * z + 2
-
-        WRITE(*,*) TRIM(varname),'interpolation ...'     
+        IF(TRIM(varname)=='tb') irec = 2 * z + 2
+        IF(TRIM(varname)=='en') irec = 12* z + 6
+ !       WRITE(*,*) TRIM(varname),' interpolation ...'     
         vert_coord_name = 'z'
         posvar='T'
         Interpolation = .TRUE.            
-
-     CASE('en')
-        varname = Ncdf_varname(i) 
-        irec = 12 * z + 6
-        WRITE(*,*) TRIM(varname),'interpolation ...'     
-        vert_coord_name = 'z'
+        ! 1D
+     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')
+        varname = Ncdf_varname(i)    
+        IF(TRIM(varname)=='gcx')  irec = 12 * z + 2
+        IF(TRIM(varname)=='gcxb') irec = 12 * z + 3
+        IF(TRIM(varname)=='sshb') irec = 12 * z + 4
+        IF(TRIM(varname)=='sshn') irec = 12 * z + 5
+ !       WRITE(*,*) TRIM(varname),' interpolation ...' 
+        vert_coord_name = 'z_b'             
         posvar='T'
-        Interpolation = .TRUE.             
-
+        Interpolation = .TRUE.     
+        !
+        ! NO interpolation
+        !
      CASE ('rotb','rotn','hdivb','hdivn')
         Interpolation = .FALSE.
         !

@@ -568,12 +572,10 @@
            SELECT CASE(posvar)
               ! 
            CASE('T')
-              !
-              IF(MAXVAL(G1%tmask(:,:,n)) == 0.) THEN          
+              IF(MAXVAL(G1%tmask(:,:,n)) == 0.) THEN
                  tabinterp4d = 0.0
-                 WRITE(*,*) 'only land points on level ',n                     
-              ELSE                       
-
+                 WRITE(*,*) 'only land points on level T ',n
+              ELSE  
                  CALL extrap_detect(G0,G1,detected_pts(:,:,n),n)                                            
 
                  CALL correct_field(detected_pts(:,:,n),tabvar1,tabvar2,&
@@ -595,6 +597,7 @@
                  CALL Correctforconservation(tabvar1(:,:,1,1),tabinterp4d(:,:,1,1), &
                       G0%e1t,G0%e2t,G1%e1t,G1%e2t,nxfin,nyfin,posvar,imin-jpizoom+1,jmin-jpjzoom+1)
 
+                 CALL check_interpextrap(varname,Child_file,tabinterp4d,G1,t,n,posvar)
 
               ENDIF
 
@@ -604,8 +607,8 @@
               !
               IF(MAXVAL(G1%umask(:,:,n)) == 0) THEN
                  tabinterp4d = 0.0
-                 WRITE(*,*) 'only land points on level ',n  
-              ELSE     
+                 WRITE(*,*) 'only land points on level U ',n  
+              ELSE
                  !
                  CALL extrap_detect(G0,G1,detected_pts(:,:,n),n,'U')  
                  CALL correct_field(detected_pts(:,:,n),tabvar1,tabvar2,&
@@ -627,6 +630,8 @@
                  CALL Correctforconservation(tabvar1(:,:,1,1),tabinterp4d(:,:,1,1), &
                       G0%e1u,G0%e2u,G1%e1u,G1%e2u,nxfin,nyfin,posvar,imin-jpizoom+1,jmin-jpjzoom+1)
 
+                 CALL check_interpextrap(varname,Child_file,tabinterp4d,G1,t,n,posvar)
+
               ENDIF
 
               tabinterp4d(:,:,1,1) =  tabinterp4d(:,:,1,1) * G1%umask(:,:,n)
@@ -635,8 +640,8 @@
               !     
               IF(MAXVAL(G1%vmask(:,:,n)) == 0) THEN
                  tabinterp4d = 0.0
-                 WRITE(*,*) 'only land points on level ',n 
-              ELSE     
+                 WRITE(*,*) 'only land points on level V ',n 
+              ELSE
                  !
 
                  CALL extrap_detect(G0,G1,detected_pts(:,:,n),n,'V')
@@ -660,6 +665,8 @@
                  CALL Correctforconservation(tabvar1(:,:,1,1),tabinterp4d(:,:,1,1), &
                       G0%e1v,G0%e2v,G1%e1v,G1%e2v,nxfin,nyfin,posvar,imin-jpizoom+1,jmin-jpjzoom+1)
 
+                 CALL check_interpextrap(varname,Child_file,tabinterp4d,G1,t,n,posvar)
+
               ENDIF
 
               tabinterp4d(:,:,1,1) =  tabinterp4d(:,:,1,1) * G1%vmask(:,:,n)

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)

Change History (1)

Changed 7 years ago by jharlass

routine checking for missing values: check_interpextrap

Note: See TracTickets for help on using tickets.