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/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/ICE_RHEO/EXPREF – NEMO

source: NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/ICE_RHEO/EXPREF/make_INITICE.py @ 14021

Last change on this file since 14021 was 14021, checked in by laurent, 3 years ago

Caught up with trunk rev 14020...

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1#!/usr/bin/python
2
3import os,sys
4from netCDF4 import Dataset as netcdf
5import numpy as np
6
7resname=''
8
9# input file
10fcoord='mesh_mask.nc'
11
12# output file
13fflx='initice.nc'
14
15print '   creating init ice file  ' +fflx
16
17# Reading coordinates file
18nccoord=netcdf(fcoord,'r')
19nav_lon=nccoord.variables['glamt'][0,:,:]
20nav_lat=nccoord.variables['gphit'][0,:,:]
21time_counter=1
22LON1= nav_lon.shape[1]
23LAT1= nav_lon.shape[0]
24print 'nav_lon.shape[1]' ,nav_lon.shape[1]
25print 'LON1 ', LON1
26print 'LAT1 ', LAT1
27
28# Creating INITICE netcdf file
29nc=netcdf(fflx,'w')
30nc.createDimension('y',LAT1)
31nc.createDimension('x',LON1)
32nc.createDimension('time_counter',None)    # Setting dimension size to 0 or None makes it unlimited.
33
34cdflon=nc.createVariable('nav_lon','f',('y','x'))
35cdflat=nc.createVariable('nav_lat','f',('y','x'))
36cdftimecounter=nc.createVariable('time_counter','f',('time_counter'))
37
38# ati : Fraction of open waters in sea ice - units %
39# hti : Sea ice thickness - units m
40# hts : Snow thickness - units m
41# smi : Sea ice salinity:
42# tmi : Sea ice internal temperature - units K
43# tsu : Sea ice surface temperature - units K
44#
45# Take constant values from namelist &namiceini of NEMO
46rn_hti_ini=2.0
47rn_hts_ini=0.1            #  initial real snow thickness (m)
48rn_ati_ini=0.99           #  initial ice concentration   (-)
49rn_smi_ini=6.3            #  initial ice salinity     (g/kg)
50rn_tmi_ini=270.           #  initial ice/snw temperature (K)
51rn_tsu_ini=270.           #  initial sea ice temperature (K)
52#
53cdfati=nc.createVariable('ati','f',('time_counter','y','x'))
54cdfati.units='Percentage'
55cdfati.long_name='Sea ice concentration'
56cdfhti=nc.createVariable('hti','f',('time_counter','y','x'))
57cdfhti.long_name='Sea ice thickness'
58cdfhti.units='m'
59cdfhts=nc.createVariable('hts','f',('time_counter','y','x'))
60cdfhts.long_name='Snow thickness'
61cdfhts.units='m'
62cdfsmi=nc.createVariable('smi','f',('time_counter','y','x'))
63cdfsmi.long_name='Sea ice salinity'
64cdfsmi.units='pss'
65cdftmi=nc.createVariable('tmi','f',('time_counter','y','x'))
66cdftmi.long_name='Sea ice internal temperature'
67cdftmi.units='Kelvin'
68cdftsu=nc.createVariable('tsu','f',('time_counter','y','x'))
69cdftsu.long_name='Sea ice surface temperature'
70cdftsu.units='Kelvin'
71
72cdflon[:,:]=nav_lon[:,:]
73cdflat[:,:]=nav_lat[:,:]
74cdftimecounter[0]=1
75
76cdfati[:,:,:]=rn_ati_ini
77cdfhts[:,:,:]=rn_hts_ini
78cdfsmi[:,:,:]=rn_smi_ini
79cdftmi[:,:,:]=rn_tmi_ini
80cdftsu[:,:,:]=rn_tsu_ini
81
82# --- add noise in initial thickness to help nucleation of deformation ---
83#for y in np.arange(1,1000,1) :
84#    for x in np.arange(1,1000,1) :
85#        cdfhti[:,y,x] = rn_hti_ini+0.02*rn_hti_ini*np.random.uniform(-1,1)
86cdfhti[:,:,:]=rn_hti_ini
87
88nc.close()
89nccoord.close()
90
91#sys.exit()
Note: See TracBrowser for help on using the repository browser.