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.
make_initice.py in NEMO/trunk/tests/ICE_ADV1D/EXPREF – NEMO

source: NEMO/trunk/tests/ICE_ADV1D/EXPREF/make_initice.py @ 10513

Last change on this file since 10513 was 10413, checked in by clem, 5 years ago

merge dev_r9947_SI3_advection with the trunk. All sette tests passed. There is probably a conservation issue with the new advection scheme that I should solve but the routine icedyn_adv_umx.F90 is going to change anyway in the next couple of weeks. At worst, the old routine can be plugged without harm

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1#!/usr/bin/python
2
3import os,sys
4from netCDF4 import Dataset as netcdf
5import numpy as np
6import matplotlib.pyplot as plt
7from math import exp
8from math import ceil
9
10resname=''
11
12# input file
13###fcoord='coordinates_'+str(resname)+'.nc'
14#fcoord='mesh_mask_'+str(resname)+'.nc'
15fcoord='mesh_mask.nc'
16
17# output file
18#fflx='initice_'+str(resname)+'.nc'
19fflx='initice_60pts.nc'
20
21print '   creating init ice file  ' +fflx
22
23# Reading coordinates file
24nccoord=netcdf(fcoord,'r')
25nav_lon=nccoord.variables['nav_lon']
26nav_lat=nccoord.variables['nav_lat']
27time_counter=1
28LON1= nav_lon.shape[1]
29LAT1= nav_lon.shape[0]
30print 'nav_lon.shape[1]' ,nav_lon.shape[1]
31print 'LON1 ', LON1
32print 'LAT1 ', LAT1
33
34# Creating INITICE netcdf file
35nc=netcdf(fflx,'w')
36nc.createDimension('y',LAT1)
37nc.createDimension('x',LON1)
38nc.createDimension('time_counter',None)    # Setting dimension size to 0 or None makes it unlimited.
39
40cdflon=nc.createVariable('nav_lon','f',('y','x'))
41cdflat=nc.createVariable('nav_lat','f',('y','x'))
42cdftimecounter=nc.createVariable('time_counter','f',('time_counter'))
43
44# ati : Fraction of open waters in sea ice - units %
45# hti : Sea ice thickness - units m
46# hts : Snow thickness - units m
47# smi :
48# tmi : Sea ice internal temperature - units K
49# tsu : Sea ice surface temperature - units K
50#
51# Take constant values from namelist &namiceini of NEMO
52rn_hti_ini=2.0
53rn_hts_ini=0.2            #  initial real snow thickness (m)
54rn_ati_ini=0.9            #  initial ice concentration   (-)
55rn_smi_ini=6.3            #  initial ice salinity     (g/kg)
56rn_tmi_ini=270.           #  initial ice/snw temperature (K)
57rn_tsu_ini=270.           #  initial sea ice temperature (K)
58#
59cdfati=nc.createVariable('ati','f',('time_counter','y','x'))
60cdfati.units='Percentage'
61cdfati.long_name='Sea ice concentration'
62cdfhti=nc.createVariable('hti','f',('time_counter','y','x'))
63cdfhti.long_name='Sea ice thickness'
64cdfhti.units='m'
65cdfhts=nc.createVariable('hts','f',('time_counter','y','x'))
66cdfhts.long_name='Snow thickness'
67cdfhts.units='m'
68cdfsmi=nc.createVariable('smi','f',('time_counter','y','x'))
69cdfsmi.long_name='Sea ice salinity'
70cdfsmi.units='pss'
71cdftmi=nc.createVariable('tmi','f',('time_counter','y','x'))
72cdftmi.long_name='Sea ice internal temperature'
73cdftmi.units='Kelvin'
74cdftsu=nc.createVariable('tsu','f',('time_counter','y','x'))
75cdftsu.long_name='Sea ice surface temperature'
76cdftsu.units='Kelvin'
77
78cdflon[:,:]=nav_lon[:,:]
79cdflat[:,:]=nav_lat[:,:]
80cdftimecounter[0]=1
81
82# Fill fields
83#print 'cdfati[:,1]', cdfati[:,1]  -> 32 values
84
85# Add a gaussian for sea ice thickness here
86cdfhti[:,:,:]=0.
87cdfhts[:,:,:]=0.
88cdfati[:,:,:]=0.
89cdfsmi[:,:,:]=0.
90cdftmi[:,:,:]=rn_tmi_ini
91cdftsu[:,:,:]=rn_tsu_ini
92
93# --------------------------------------
94# for basin=99x99km with dx=1km ; dy=1km
95
96# --- Lipscomb 2004 experiment ---
97cdfhti[:,:,:]=1.
98# thickness
99for y in np.arange(0,LAT1,1) :
100    for x in np.arange(0,LON1,1) :
101        if (x >= 15. and x <= 43.):
102            cdfhti[:,y,x] = 0.2
103#        elif (x < 10. or x > 50.):
104#            cdfhti[:,y,x] = 0.
105
106cdfati[:,:,:]=0.001
107# concentration
108for y in np.arange(0,LAT1,1) :
109    for x in np.arange(0,LON1,1) :
110        if (x >= 10. and x <= 29.):
111            cdfati[:,y,x] = 0.9 * (x - 9.) / 20.
112        elif (x > 29. and x <= 48.):
113            cdfati[:,y,x] = 0.9
114
115# ---------------------------------------
116
117nc.close()
118nccoord.close()
119
120#sys.exit()
Note: See TracBrowser for help on using the repository browser.