diff --git a/sources/amip-forcing/src/python/amip_forcing.py b/sources/amip-forcing/src/python/amip_forcing.py index bcfa1fffa364fc0308241d0713aaacbb4ef747f4..57fe2798c22fa649e6dcf6ee8c31a93b2bfe8aaf 100644 --- a/sources/amip-forcing/src/python/amip_forcing.py +++ b/sources/amip-forcing/src/python/amip_forcing.py @@ -1,11 +1,12 @@ #!/usr/bin/env python3 -# Copyright 2021 - Barcelona Supercomputing Center -# Author: Rodrigo Martín Posada +# Copyright 2022 - Barcelona Supercomputing Center +# Authors: Rodrigo Martín Posada, Etienne Tourigny # MIT License import pyoasis from pyoasis import OASIS # pylint: disable=no-name-in-module import numpy as np import logging +import math from amip_forcing_mod import AMIPForcing from amip_utils import read_namelist @@ -14,6 +15,12 @@ from amip_utils import read_namelist LOG_FILE_NAME = 'amip.log' CPLNG_COMP_NAME = 'AMIPFORC' +#Options +write_grid = True +write_grid_mask = True +write_grid_corners = True +write_grid_areas = True + if __name__ == '__main__': # Read RunLengthSec,TimeStepSec from namelist RunLengthSec, TimeStepSec, StartYear, StartMonth, \ @@ -40,26 +47,65 @@ if __name__ == '__main__': # Setup amip = AMIPForcing(deltaT, FixYear, StartYear, vars_config) + amip_vars = [v.id for v in amip.vars] + logging.debug('amip vars: {}'.format(str(amip_vars))) # OASIS init comp = pyoasis.Component(CPLNG_COMP_NAME) + # Write grids oasis_vars = {} grids_names = np.unique([v.grid_name for v in amip.vars]) + logging.debug('grids_names: {}'.format(str(grids_names))) for grid_name in grids_names: # Get OASIS vars within this grid_name grid_vars = list(filter(lambda x: x.grid_name == grid_name, amip.vars)) v = grid_vars[0] - grid_ny, grid_nx = v.grid_lat.shape + grid_nx = v.grid_nx + grid_ny = v.grid_ny # Create partition partition = pyoasis.SerialPartition(grid_nx*grid_ny) - # Write the grid - grid = pyoasis.Grid(grid_name, grid_nx, grid_ny, v.grid_lon, v.grid_lat, partition) - grid.set_mask(np.zeros(v.grid_lon.shape)) - grid.write() + # Define the grid and write to files + if write_grid: + grid = pyoasis.Grid(grid_name, grid_nx, grid_ny, v.grid_lon, v.grid_lat, partition) + # add grid mask + if write_grid_mask: + grid.set_mask(np.zeros(v.grid_lon.shape)) + # add grid corners + if write_grid_corners: + ncrn = 4 + clo = pyoasis.asarray(np.zeros((grid_nx, grid_ny, ncrn), dtype=np.float64)) + clo[:, :, 0] = v.grid_lon[:, :] - v.dx/2.0 + clo[:, :, 1] = v.grid_lon[:, :] + v.dx/2.0 + clo[:, :, 2] = clo[:, :, 1] + clo[:, :, 3] = clo[:, :, 0] + cla = pyoasis.asarray(np.zeros((grid_nx, grid_ny, ncrn), dtype=np.float64)) + cla[:, :, 0] = v.grid_lat[:, :] - v.dy/2.0 + cla[:, :, 1] = cla[:, :, 0] + cla[:, :, 2] = v.grid_lat[:, :] + v.dy/2.0 + cla[:, :, 3] = cla[:, :, 2] + grid.set_corners(clo, cla) + # add grid areas + if write_grid_areas: + dp_conv = math.pi/180. + area = np.zeros((grid_nx, grid_ny), dtype=np.float64) + area[:, :] = dp_conv * \ + np.abs(np.sin(cla[:, :, 2] * dp_conv) - + np.sin(cla[:, :, 0] * dp_conv)) * \ + np.abs(clo[:, :, 1] - clo[:, :, 0]) + grid.set_area(area) + # write grid to files + grid.write() + # Set vars for v in grid_vars: - oasis_vars[v] = pyoasis.Var(v.oasis_name, partition, OASIS.OUT) + if not v.oasis_name in oasis_vars: + logging.debug('creating oasis var {} with grid {}'.format(v.oasis_name, grid_name)) + oasis_vars[v.oasis_name] = (v, pyoasis.Var(v.oasis_name, partition, OASIS.OUT)) + else: + logging.debug('not creating oasis var {} with grid {} as it hs already been defined'.format(v.oasis_name, grid_name)) + logging.debug('oasis_vars: {}'.format(str(oasis_vars.keys()))) + comp.enddef() amip.setup_amip_forcing(StartYear, StartMonth, StartDay) @@ -71,8 +117,15 @@ if __name__ == '__main__': amip.update_vars() # OASIS put for each var - for amip_v, oa_v in oasis_vars.items(): - oa_v.put(time, amip_v.send_field) + for var_name, (amip_v, oa_v) in oasis_vars.items(): + logging.debug('sending var {} at time {}'.format(str(var_name),time)) + #oa_v.put(time, amip_v.send_field) + send_field = 0 + for v in amip.vars: + if v.oasis_name == var_name: + send_field += v.send_field + logging.debug('accumulating {} from amip var {} for oasis var {} total= {}'.format(str(v.send_field), v.id, var_name,str(send_field))) + oa_v.put(time, send_field) amip.finalise_amip_forcing() diff --git a/sources/amip-forcing/src/python/amip_var.py b/sources/amip-forcing/src/python/amip_var.py index 24b480ac9fb5357b52aa7c6deb4ca53a8a833d82..0acf932a07d75453f011192f7a79acaea966e2a4 100644 --- a/sources/amip-forcing/src/python/amip_var.py +++ b/sources/amip-forcing/src/python/amip_var.py @@ -7,7 +7,7 @@ import numpy as np from datetime import date, timedelta from amip_utils import days_since_refyear, filename_from_pattern - +import pyoasis class AMIPVar: def __init__(self, conf, fix_year, start_year): @@ -26,10 +26,9 @@ class AMIPVar: self.fix_year = fix_year # Initialization self.__get_grids(start_year) - grid_shape = self.grid_lat.shape - self.field = np.empty((2,) + grid_shape) + self.field = pyoasis.asarray(np.empty((2,self.grid_nx,self.grid_ny))) # Field that will be sent - self.send_field = np.empty(grid_shape) + self.send_field = pyoasis.asarray(np.empty((self.grid_nx,self.grid_ny))) # Current netCDF dataset self.dataset = None # Name of the current dataset file @@ -76,6 +75,8 @@ class AMIPVar: def update(self, t_global): t_local = self.t0101 + t_global + logging.debug('update var {} at time {}'.format(self.id, t_local)) + while t_local > self.t2: self.__read_next_timestep_from_files(t_local) @@ -125,26 +126,53 @@ class AMIPVar: file_name = filename_from_pattern(self.file_pattern, date(yy, 1, 1)) ds = Dataset(file_name, 'r') variable_names = ds.variables.keys() - # Look for lat and lon variables + + # Look for lat and lon variables to create a 2d grid. + # If not found, look for sector to greate a 1d grid (only 3 sectors for co2 supported for now). if 'lat' in variable_names: lat = ds['lat'][:] elif 'latitude' in variable_names: lat = ds['latitude'][:] else: - raise Exception( - 'AMIP: {}: Could not found lat or latitude variable name. Invalid input netCDF file {}.'.format(self.id, file_name)) + #raise Exception( + # 'AMIP: {}: Could not find lat or latitude variable name. Invalid input netCDF file {}.'.format(self.id, file_name)) + lat = None if 'lon' in variable_names: lon = ds['lon'][:] elif 'longitude' in variable_names: lon = ds['longitude'][:] else: - raise Exception( - 'AMIP: {}: Could not found lon or longitude variable name. Invalid input netCDF file {}.'.format(self.id, file_name)) - grid_ny = lat.size - grid_nx = lon.size - # Create 2-D grid for OASIS - self.grid_lon = np.tile(lon, (grid_ny, 1)) - self.grid_lat = np.repeat(np.reshape(lat, (grid_ny, 1)), grid_nx, axis=1) + #raise Exception( + # 'AMIP: {}: Could not find lon or longitude variable name. Invalid input netCDF file {}.'.format(self.id, file_name)) + lon = None + if lat is None or lon is None: + if 'sector' in variable_names: + num_sectors = len(ds['sector'][:]) + if num_sectors == 3: + self.grid_ny = 2 + self.grid_nx = 1 + lat=[-45,45] + lon=0 + self.dy=lat[1]-lat[0] + self.dx=0 + # Create 2-D grid for OASIS + self.grid_lon = np.tile(lon, (self.grid_ny, 1)).T + self.grid_lat = np.tile(lat, (self.grid_nx, 1)) + else: + raise Exception( + 'AMIP: {}: Could not find sector variable of length 3. Invalid input netCDF file {}.'.format(self.id, file_name)) + else: + raise Exception( + 'AMIP: {}: Could not find lon or longitude variable name. Invalid input netCDF file {}.'.format(self.id, file_name)) + else: + self.grid_ny = lat.size + self.grid_nx = lon.size + self.dy=lat[1]-lat[0] + self.dx=lon[1]-lon[0] + # Create 2-D grid for OASIS + self.grid_lon = np.tile(lon, (self.grid_ny, 1)).T + self.grid_lat = np.tile(lat, (self.grid_nx, 1)) + ds.close() def __read_next_timestep_from_files(self, t_local): @@ -189,11 +217,16 @@ class AMIPVar: raw_field = self.dataset[self.var_name][self.t_index] # This section can be "hardcoded" by the user - # Hardcoded CO2 emissions data. Read only sector id 1: Energy - if self.var_name == 'CO2_em_anthro': - raw_field = raw_field[1] - - self.field[1] = raw_field.astype('float64')*self.scale_factor+self.offset + # Hardcoded CO2 emissions data. + logging.debug('reading {}'.format(self.var_name)) + if self.var_name == 'CO2_em_anthro' or self.var_name == 'CO2_em_AIR_anthro': + #Read sum of all sectors / levels + raw_field = np.sum(raw_field,axis=0) + elif self.var_name == 'mole_fraction_of_carbon_dioxide_in_air': + raw_field = raw_field[1:] + logging.debug('reading co2 raw_field={} raw_field.shape={} field.shape={}'.format(str(raw_field),str(raw_field.shape),str(self.field[1].shape))) + + self.field[1] = pyoasis.asarray(np.transpose(raw_field)).astype('float64')*self.scale_factor+self.offset def __close_current_file(self): logging.debug('{}: close file {}'.format(self.id, self.current_file)) diff --git a/tests/IFS_mock.py b/tests/IFS_mock.py index a3eb04269719734c170ca145788e1edb42775309..ebea31c3a080577d07f98cf30e4561137dc16830 100755 --- a/tests/IFS_mock.py +++ b/tests/IFS_mock.py @@ -52,7 +52,7 @@ if __name__ == '__main__': with open('namcouple', 'r') as f: contents = f.read() - if 'AMIP_emissions' in contents: + if 'CO2_conc' in contents: CO2_MODE = True if 'L080' in contents: nx = L080_NX @@ -65,8 +65,17 @@ if __name__ == '__main__': # Definition of the local partition il_size, il_offset = def_local_partition(nx, npes, mype) logging.debug('Local partition definition') - logging.debug('il_size, il_offset = {} {}'.format(il_size, il_offset)) + logging.debug('il_size = {} il_offset = {} mype = {}'.format(il_size, il_offset, mype)) partition = pyoasis.ApplePartition(il_offset, il_size) + if CO2_MODE: + nx_co2 = 2 + if mype == 0: + logging.debug('Local serial partition') + logging.debug('nx_co2 = {} mype = {}'.format(nx_co2, mype)) + partition2 = pyoasis.SerialPartition(nx_co2) + else: + nx_co2 = 0 + partition2 = None # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # DECLARATION OF THE COUPLING FIELDS @@ -76,8 +85,11 @@ if __name__ == '__main__': A_Ice_frac = pyoasis.Var("A_Ice_frac", partition, OASIS.IN) logging.debug('var_id A_SST, var_id A_Ice_frac {} {}'.format(A_SST._id, A_Ice_frac._id)) if CO2_MODE: - A_emissions = pyoasis.Var("A_emissions", partition, OASIS.IN) - logging.debug('var_id A_emissions {}'.format(A_emissions._id)) + A_CO2_emis = pyoasis.Var("A_CO2_emis", partition, OASIS.IN) + logging.debug('var_id A_CO2_emis {}'.format(A_CO2_emis._id)) + if mype == 0: + A_CO2_conc = pyoasis.Var("A_CO2_conc", partition2, OASIS.IN) + logging.debug('var_id A_CO2_conc {}'.format(A_CO2_conc._id)) # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # TERMINATION OF DEFINITION PHASE @@ -93,7 +105,10 @@ if __name__ == '__main__': field_recv_A_SST = pyoasis.asarray(np.full(il_size, -1.0)) field_recv_A_Ice_frac = pyoasis.asarray(np.full(il_size, -1.0)) - field_recv_A_emissions = pyoasis.asarray(np.full(il_size, -1.0)) + field_recv_A_CO2_emis = pyoasis.asarray(np.full(il_size, -1.0)) + if CO2_MODE and mype == 0: + field_recv_A_CO2_conc = pyoasis.asarray(np.full(nx_co2, -1.0)) + for itap_sec in range(0, RUN_LENGTH_SEC, COUPLING_INTERVAL): A_SST.get(itap_sec, field_recv_A_SST) A_Ice_frac.get(itap_sec, field_recv_A_Ice_frac) @@ -108,11 +123,11 @@ if __name__ == '__main__': np.mean(field_recv_A_Ice_frac), np.max(field_recv_A_Ice_frac))) if CO2_MODE: - A_emissions.get(itap_sec, field_recv_A_emissions) - logging.debug('A_emissions -> {:.3e} {:.3e} {:.3e}'.format( - np.min(field_recv_A_emissions), - np.mean(field_recv_A_emissions), - np.max(field_recv_A_emissions))) + A_CO2_emis.get(itap_sec, field_recv_A_CO2_emis) + logging.debug('A_CO2_emis -> {:.3e} {:.3e} {:.3e}'.format( np.min(field_recv_A_CO2_emis), np.mean(field_recv_A_CO2_emis), np.max(field_recv_A_CO2_emis))) + if mype == 0: + A_CO2_conc.get(itap_sec, field_recv_A_CO2_conc) + logging.debug('A_CO2_conc -> {:.3e} {:.3e} {:.3e}'.format( np.min(field_recv_A_CO2_conc), np.mean(field_recv_A_CO2_conc), np.max(field_recv_A_CO2_conc))) logging.debug('--------------------------------------\n') # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/tests/data/areas-noamip.nc b/tests/data/areas-noamip.nc index 72606060671aef345ffaf78be31fe4fe46649782..734e08de2556659bb269b30afc5a6d02cd1536af 100644 Binary files a/tests/data/areas-noamip.nc and b/tests/data/areas-noamip.nc differ diff --git a/tests/data/convert-ece4pyreader-grids.sh b/tests/data/convert-ece4pyreader-grids.sh index 11dee75182f18c34ca2f755bd2834d22ae36d514..22533af2fb9d546480471c62b4104d4a811641c2 100755 --- a/tests/data/convert-ece4pyreader-grids.sh +++ b/tests/data/convert-ece4pyreader-grids.sh @@ -13,10 +13,19 @@ gridname_ifs=L128 griddef_ifs=ICMGGa22e+000000 # copy from /gpfs/scratch/bsc32/bsc32051/pub/scripts/convert-tm5-grids gridname_AMIP=AMIP griddef_amip=grid-amip.txt # cdo griddes tosbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-3_gn_187001-201706.nc > grid-amip.txt +gridname_co2=CO2 +griddef_co2=grid-co2_emis.txt # cdo griddes > grid-co2_emis.txt model_ifs=IFS_MOCK vars_ifs="A_SST A_Ice_frac" +[[ `grep CO2_conc namcouple` != "" ]] && CO2_MODE=true || CO2_MODE=false +[[ ${CO2_MODE} == true ]] && vars_ifs+=" A_CO2_emis" + model_amip=AMIPFORC vars_amip="AMIP_sst AMIP_sic" +model_co2=AMIPFORC +[[ ${CO2_MODE} == true ]] && vars_co2="AMIP_CO2_emis" || vars_co2="" +grids="AMIP L128" #B128 A128 R128 +[[ ${CO2_MODE} == true ]] && grids+=" CO2_emis" for v in $vars_ifs do @@ -29,27 +38,35 @@ do HDF5_DISABLE_VERSION_CHECK=1 cdo -O -f nc -r $taxis -setgrid,${griddir}/${griddef_amip} ${v}_${model_amip}_??.nc ${v}.nc done +for v in $vars_co2 +do + HDF5_DISABLE_VERSION_CHECK=1 cdo -O -f nc -r $taxis -setgrid,${griddir}/${griddef_co2} ${v}_${model_co2}_??.nc ${v}.nc +done # copy from a runtime dir the following files grids.nc areas.nc masks.nc -for gridname in AMIP L128 # B128 A128 R128 +for gridname in ${grids} do if [[ ${gridname} == AMIP ]] ; then format=nc suffix=".nc" griddef=${griddef_amip} + elif [[ ${gridname} == CO2_emis ]] ; then + format=nc + suffix=".nc" + griddef=${griddef_co2} else format=grb1 suffix=".grb" griddef=${griddef_ifs} fi cdo -f $format -setgrid,${griddir}/${griddef} -selvar,${gridname}.msk masks.nc masks_${gridname}${suffix} - # cdo -f $format -setgrid,${griddir}/${griddef} -selvar,${gridname}.srf areas.nc areas_${gridname}${suffix} + cdo -f $format -setgrid,${griddir}/${griddef} -selvar,${gridname}.srf areas.nc areas_${gridname}${suffix} + if [[ ${format} == "grb1" ]] ; then + for t in masks areas ; do + cdo -f nc -setgridtype,regularnn ${t}_${gridname}.grb ${t}_${gridname}.nc + done + fi done -for gridname in L128 # B128 A128 R128 -do -cdo -f nc -setgridtype,regularnn masks_${gridname}.grb masks_${gridname}.nc -# cdo -f nc -setgridtype,regularnn areas_${gridname}.grb areas_${gridname}.nc -done diff --git a/tests/data/grids-noamip.nc b/tests/data/grids-noamip.nc index 234fa09f0d2c1000071bc621f0f59c4dbe6946cb..fad7dbcd06d16704700bd68579ad20abbd3bf7dc 100644 Binary files a/tests/data/grids-noamip.nc and b/tests/data/grids-noamip.nc differ diff --git a/tests/data/masks-noamip.nc b/tests/data/masks-noamip.nc index d52436d3f75498506d9f0e151a0d772abd3a9643..86fd2332dd05dd1f8854b84bead278067236c061 100644 Binary files a/tests/data/masks-noamip.nc and b/tests/data/masks-noamip.nc differ diff --git a/tests/data/namcouple.sh b/tests/data/namcouple.sh index fd57e51d21f31b495218f96d8ce5fe3a7328313a..f04b0e3799faefb08fdf675b18eb06441879fa3e 100755 --- a/tests/data/namcouple.sh +++ b/tests/data/namcouple.sh @@ -20,11 +20,11 @@ cat << EOF # ================================================================================================= # --- AMIP forcing data --- [ifs amip] AMIP_sst:AMIP_sic A_SST:A_Ice_frac 1 86400 1 rstas.nc EXPOUT - AMIP ${ifs_grid} LAG=0 + AMIP L${ifs_grid} LAG=0 P 0 P 0 SCRIPR GAUSWGT LR SCALAR LATITUDE 1 9 2.0 # ------------------------------------------------------------------------------------------------- \$END # ================================================================================================= -EOF \ No newline at end of file +EOF diff --git a/tests/data/namcouple_co2.sh b/tests/data/namcouple_co2.sh index d868753d0e2abd8cc2d43954cbb42b47e667a83f..eb345536aeb9425848defddcd903992052bd9d4a 100644 --- a/tests/data/namcouple_co2.sh +++ b/tests/data/namcouple_co2.sh @@ -3,7 +3,7 @@ cat << EOF # General OASIS configuration # ================================================================================================= \$NFIELDS - 2 + 3 \$END # ------------------------------------------------------------------------------------------------- \$RUNTIME @@ -20,17 +20,23 @@ cat << EOF # ================================================================================================= # --- AMIP forcing data --- [ifs amip] AMIP_sst:AMIP_sic A_SST:A_Ice_frac 1 86400 1 rstas.nc EXPOUT - AMIP ${ifs_grid} LAG=0 + AMIP L${ifs_grid} LAG=0 P 0 P 0 SCRIPR GAUSWGT LR SCALAR LATITUDE 1 9 2.0 - AMIP_emissions A_emissions 1 86400 1 rstas.nc EXPOUT - CO2 ${ifs_grid} LAG=0 + AMIP_CO2_emis A_CO2_emis 1 86400 1 rstas.nc EXPOUT + CO2_emis B${ifs_grid} LAG=0 P 0 P 0 SCRIPR CONSERV GAUSWGT LR SCALAR LATITUDE 1 9 2.0 + + AMIP_CO2_conc A_CO2_conc 1 86400 1 rstas.nc EXPOUT + CO2_conc CO2_conc LAG=0 + P 0 P 0 + LOCTRANS + AVERAGE # ------------------------------------------------------------------------------------------------- \$END # ================================================================================================= -EOF \ No newline at end of file +EOF diff --git a/tests/data/namcouple_primavera.sh b/tests/data/namcouple_primavera.sh index b6120f069468d5af3ab7cb15e8b2fffefb5f21ed..d76a68229116c6584cdc8d0640b493cf035fe02a 100755 --- a/tests/data/namcouple_primavera.sh +++ b/tests/data/namcouple_primavera.sh @@ -20,17 +20,17 @@ cat << EOF # ================================================================================================= # --- AMIP forcing data --- [ifs amip] AMIP_sst A_SST 1 86400 1 rstas.nc EXPOUT - PSST ${ifs_grid} LAG=0 + PSST L${ifs_grid} LAG=0 P 0 P 0 SCRIPR GAUSWGT LR SCALAR LATITUDE 1 9 2.0 AMIP_sic A_Ice_frac 1 86400 1 rstas.nc EXPOUT - PSIC ${ifs_grid} LAG=0 + PSIC L${ifs_grid} LAG=0 P 0 P 0 SCRIPR GAUSWGT LR SCALAR LATITUDE 1 9 2.0 # ------------------------------------------------------------------------------------------------- \$END # ================================================================================================= -EOF \ No newline at end of file +EOF diff --git a/tests/data/namelist_python.amip.sh b/tests/data/namelist_python.amip.sh index 02473c952c04fde76e58a48cc3079bdad20570df..995be21dde028dd44acdfb8728011877a9c68d2e 100755 --- a/tests/data/namelist_python.amip.sh +++ b/tests/data/namelist_python.amip.sh @@ -8,9 +8,9 @@ cat << EOF StartMonth = ${leg_start_date_yyyymmdd:4:2} StartDay = ${leg_start_date_yyyymmdd:6:2} FixYear = ${ifs_cmip_fixyear} - ${sst_conf_var} - ${sic_conf_var} - ${co2_conf_var} +${sst_conf_var} +${sic_conf_var} +${co2_conf_var} LDebug = false !----------------------------------------------------------------------- / diff --git a/tests/data/primavera/.gitignore b/tests/data/primavera/.gitignore deleted file mode 100644 index c96a04f008ee21e260b28f7701595ed59e2839e3..0000000000000000000000000000000000000000 --- a/tests/data/primavera/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/tests/run_example.sh b/tests/run_example.sh index bf4f855daa859d1e848a867dfa694912da794b0e..07fe34fd54efed307f4acf2d6dcf37c19ee6f359 100755 --- a/tests/run_example.sh +++ b/tests/run_example.sh @@ -7,6 +7,8 @@ if [ $# -ne 8 ]; then exit 1 fi +set -xuve + lang=$1 amip_mode=$2 # forcing or primavera # - Define number of processes to run each executable @@ -52,10 +54,10 @@ rundir=${srcdir}/work_${lang}_${amip_mode}_${nproc_exe1}_${leg_start_date}_${leg # export COVERAGE_FILE=${rundir}/../.coverage echo '*****************************************************************' -echo '*** '$casename' : '$run +#echo '*** '$casename' : '$run echo '' echo 'Rundir :' $rundir -echo 'Architecture :' $arch +#echo 'Architecture :' $arch echo 'Host : '$host echo 'User : '$user echo '' @@ -73,10 +75,12 @@ ln -sf $datadir/*.txt $rundir/. if [ $amip_mode = forcing ] || [ $amip_mode = co2 ]; then ln -sf $datadir/forcing/siconcbcs*.nc $rundir/. ln -sf $datadir/forcing/tosbcs*.nc $rundir/. - ln -sf $datadir/forcing/rmp_AMIP_to_${ifs_grid}_GAUSWGT.nc $rundir/. + ln -sf $datadir/forcing/rmp_AMIP_to_L${ifs_grid}_GAUSWGT*.nc $rundir/. if [ $amip_mode = co2 ]; then ln -sf $datadir/co2/CO2-em-anthro_*.nc $rundir/. - ln -sf $datadir/co2/rmp_CO2_to_${ifs_grid}_GAUSWGT*.nc $rundir/. + ln -sf $datadir/co2/CO2-em-AIR-anthro_*.nc $rundir/. + ln -sf $datadir/co2/mole-fraction-of-carbon-dioxide-in-air_*.nc* $rundir/. + ln -sf $datadir/co2/rmp_CO2_emis_to_B${ifs_grid}_GAUSWGT*.nc $rundir/. fi else ln -sf $datadir/$amip_mode/HadI*.nc $rundir/. @@ -111,10 +115,17 @@ if [ $lang = fortran ] || [ $lang = pythoncompat ]; then fi else if [ $amip_mode = forcing ] || [ $amip_mode = co2 ]; then - sst_conf_var="Vars(1,:) = 'AMIP_sst_monthly', 'AMIP', 'AMIP_sst', 'tosbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-3_gn_187001-201706.nc', 'tosbcs', 1870, 2016, 'monthly', ${amip_interpolate}, 1, 273.15, 271.38, ," - sic_conf_var="Vars(2,:) = 'AMIP_sic_monthly', 'AMIP', 'AMIP_sic', 'siconcbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-3_gn_187001-201706.nc', 'siconcbcs', 1870, 2016, 'monthly', ${amip_interpolate}, 0.01, 0, 0, 1," + i=1 + sst_conf_var="Vars("$((i++))",:) = 'AMIP_sst_monthly', 'AMIP', 'AMIP_sst', 'tosbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-3_gn_187001-201706.nc', 'tosbcs', 1870, 2016, 'monthly', ${amip_interpolate}, 1, 273.15, 271.38, ," + sic_conf_var="Vars("$((i++))",:) = 'AMIP_sic_monthly', 'AMIP', 'AMIP_sic', 'siconcbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-3_gn_187001-201706.nc', 'siconcbcs', 1870, 2016, 'monthly', ${amip_interpolate}, 0.01, 0, 0, 1," if [ $amip_mode = co2 ]; then - co2_conf_var="Vars(3,:) = 'CO2_monthly', 'CO2', 'AMIP_emissions', 'CO2-em-anthro_input4MIPs_emissions_CMIP_CEDS-2017-05-18_gn_200001-201412.nc', 'CO2_em_anthro', 1750, 2018, 'monthly', ${amip_interpolate}, 1, 0, , ," + co2_conf_var="Vars("$((i++))",:) = 'CO2_em_monthly', 'CO2_emis', 'AMIP_CO2_emis', 'CO2-em-anthro_input4MIPs_emissions_CMIP_CEDS-2017-05-18_gn_200001-201412.nc', 'CO2_em_anthro', 1750, 2018, 'monthly', ${amip_interpolate}, 1, 0, , ," + co2_conf_var+=$'\n'"Vars("$((i++))",:) = 'CO2_em_AIR_anthro', 'CO2_emis', 'AMIP_CO2_emis', 'CO2-em-AIR-anthro_input4MIPs_emissions_CMIP_CEDS-2017-08-30_gn_200001-201412.nc', 'CO2_em_AIR_anthro', 1750, 2018, 'monthly', ${amip_interpolate}, 1, 0, , ," + #this fix is required to parse the co2 files which havereftime 0-1-1, which isn't supported by python + #cdo -R -setreftime,1849-01-01,00:00 mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_CMIP_UoM-CMIP-1-2-0_gr1-GMNHSH_184901-201412.nc mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_CMIP_UoM-CMIP-1-2-0_gr1-GMNHSH_184901-201412.nc.mod + co2_conf_var+=$'\n'"Vars("$((i++))",:) = 'CO2_conc_monthly', 'CO2_conc', 'AMIP_CO2_conc', 'mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_CMIP_UoM-CMIP-1-2-0_gr1-GMNHSH_184901-201412.nc.mod', 'mole_fraction_of_carbon_dioxide_in_air', 1849, 2014, 'monthly', false, 1, 0, , ," + else + co2_conf_var="" fi else sst_conf_var="Vars(1,:) = 'AMIP_sst_daily', 'PSST', 'AMIP_sst', 'HadISST2_prelim_0to360_alldays_sst_[year].nc', 'sst', 1850, 2016, 'daily', false, 1, 0, , ," @@ -136,7 +147,10 @@ fi echo 'Executing the model using mpirun' mpirun -np $nproc_exe1 $exe1 : -np $nproc_exe2 $exe2 -echo $casename 'is executed or submitted to queue.' +# convert output +bash convert-ece4pyreader-grids.sh ${leg_start_date} + +#echo $casename 'is executed or submitted to queue.' echo 'Results are found in rundir : '$rundir ######################################################################