2 Commits 17ddb9e68f ... 108f57acfc

Tác giả SHA1 Thông báo Ngày
  Charles Pelletier 108f57acfc isfcpl update 4 năm trước cách đây
  Charles Pelletier 316660af9a iscpl update 4 năm trước cách đây
3 tập tin đã thay đổi với 164 bổ sung113 xóa
  1. 9 7
      templates/genius/programs.cfg
  2. 9 8
      templates/lemaitre3/programs.cfg
  3. 146 98
      templates/scripts/skeleton.sh

+ 9 - 7
templates/genius/programs.cfg

@@ -19,12 +19,14 @@ xio_exe_file=${nemo_src_dir}/EXTERNAL/xios-1.0/bin/xios_server.exe
 xio_numproc=4
 
 # -----------------------------------------------------------------------------
-# *** fETISh configuration
+# *** ice sheet configuration
 # -----------------------------------------------------------------------------
 
-fetish_src_dir=${nemo_src_dir}/EXTERNAL/isfcpl_scripts
-fetish_call="matlab -nodesktop -nojvm -r fETISh_Coupling_NEMO > toto"
-pp_fetish_call="python pp_fetish_toclust_nomovfront.py"
-pp_nemo_to_fetish_call="python pp_nemo_to_fetish_cluster.py"
-fetish_modules="matlab/R2019a"
-pp_fetish_modules="mlpy; module load CDO"
+name_icesheet_model="fETISh" # only "fETISh" will be recognized
+icesheet_src_dir=${nemo_src_dir}/EXTERNAL/isfcpl_scripts
+icesheet_call="matlab -nodesktop -nojvm -r fETISh_Coupling_NEMO > toto"
+icesheet_modules="matlab/R2019a"
+pp_icesheet_to_nemo_call="python pp_fetish_toclust_nomovfront.py"
+pp_nemo_to_icesheet_call="python pp_nemo_to_fetish_cluster.py"
+
+

+ 9 - 8
templates/lemaitre3/programs.cfg

@@ -1,4 +1,4 @@
-module_list="2016a netCDF-Fortran/4.4.4-intel-2016a"
+module_list="releases/2018b netCDF-Fortran/4.4.4-intel-2018b"
 extralibs_list=""
 
 # -----------------------------------------------------------------------------
@@ -18,12 +18,13 @@ xio_exe_file=${nemo_src_dir}/EXTERNAL/xios-1.0/bin/xios_server.exe
 xio_numproc=4
 
 # -----------------------------------------------------------------------------
-# *** fETISh configuration
+# *** ice sheet configuration
 # -----------------------------------------------------------------------------
 
-fetish_src_dir=${nemo_src_dir}/EXTERNAL/isfcpl_scripts
-fetish_call="matlab -nodesktop -nojvm -r fETISh_Coupling_NEMO > toto"
-pp_fetish_call="python pp_fetish_toclust_nomovfront.py"
-pp_nemo_to_fetish_call="python pp_nemo_to_fetish_cluster.py"
-fetish_modules="matlab/R2019a"
-pp_fetish_modules="mlpy; module load CDO"
+name_icesheet_model="fETISh" # only "fETISh" will be recognized
+icesheet_src_dir=${nemo_src_dir}/EXTERNAL/isfcpl_scripts
+icesheet_call="./launchjob_Lemaitre3_fETISh_compiled.sh"
+icesheet_init_geom_file="fETISH_8km_geometry_init.nc"
+# icesheet_modules="matlab/R2019a"
+pp_icesheet_to_nemo_call="python pp_fetish_toclust_nomovfront.py"
+pp_nemo_to_icesheet_call="python pp_nemo_to_fetish_cluster.py"

+ 146 - 98
templates/scripts/skeleton.sh

@@ -37,19 +37,34 @@ function leap_days()
 }
 
 
-function mlpy () {
+function ml_pp_ice () {
+    if [[ ${USER} == "vsc"????? ]]; then
+	if [[ "${name_icesheet_model}" == "fETISh" ]]; then
+	    module purge
+	    module load Python
+	    PYTHONPATH="${HOME}/.local/bin:${HOME}/.local/lib/python3.7/site-packages:\${PYTHONPATH}"
+	    module load CDO
+	    echo ${PYTHONPATH} > ${start_dir}/ppath
+	    echo "genius and fetish detected" > ${start_dir}/tmpout
+	else
+	    echo "On Genius, ice sheet models other than fETISh not implemented yet" > ${start_dir}/tmpout
+	    exit 2
+	fi
+    elif [[ ${HOSTNAME} == "lm3"* ]]; then
+	if [[ "${name_icesheet_model}" == "fETISh" ]]; then
+	    echo "lemaitre3 and fetish detected" > ${start_dir}/tmpout
+	    module purge
+	    module load releases/2018a CDO/1.8.2-intel-2018a Python/3.6.4-intel-2018a
+	    # PYTHONPATH="${HOME}/.local/lib/python3.6/site-packages:${PYTHONPATH}"
+	    # module load NCO CDO
+	else
+	    echo "On lemaitre3, ice sheet models other than fETISh not implemented yet" > ${start_dir}/tmpout
+	    exit 2
+	fi
 
-    if [[ `hostname` == "ozone" ]]; then
-	module purge
-	module load Python
-	PYTHONPATH="/elic/home/pelletie/.local/lib/python3.6/site-packages:${PYTHONPATH}"
-    elif [[ ${USER} == "vsc"????? ]]; then
-	module purge
-	module load Python
-	PYTHONPATH="/user/leuven/327/vsc32749/.local/bin:/user/leuven/327/vsc32749/.local/lib/python3.7/site-packages:${PYTHONPATH}"
     else
-	echo "Nothing detected ${USER}" > ${start_dir}/tmpout
-	exit 0
+	echo "hostname undetected. not implemented yet." > ${start_dir}/tmpout
+	exit 2
     fi
 }
 
@@ -101,6 +116,10 @@ cd "${run_dir}"
 # cp -u "${nem_exe_file:?}" .
 # cp -u "${xio_exe_file:?}" .
 
+# nem_exe_bn=`basename ${nem_exe_file}`
+# xio_exe_bn=`basename ${xio_exe_file}`
+
+
 # Write fake file for previous fresh water budget adjustment (nn_fwb==2 in namelist)
 [[ ! -f EMPave_old.dat ]] && echo "                               0  0.0000000000000000E+00  0.0000000000000000E+00" > EMPave_old.dat
 #TODO: Enquiry about this
@@ -122,6 +141,20 @@ done
 
 if [ "${isfcpl}" == "1" ]; then
 
+    if [[ ${USER} == "vsc"????? ]]; then
+	echo "Genius and iscpl detected. OK."
+    elif [[ ${HOSTNAME} == "lm3"* ]]; then
+	echo "Lemaitre3 and iscpl detected. OK."
+    else
+	echo "You have asked for iscpl, but I have not recognized genius nor lemaitre3. Exiting."
+	exit 2
+    fi
+    
+    if [ "${name_icesheet_model}" != "fETISh" ]; then
+	echo "only \"fETISh\" is known as an ice sheet model. exiting."
+	exit 2
+    fi
+    
     length_cut_pref=$(( ${#exp_name} + 4 ))
     rebuild_nemo_exe=${nemo_src_dir}/TOOLS/REBUILD_NEMO/rebuild_nemo
     if [ -f ${start_dir}/isfcpl.track ]; then
@@ -129,8 +162,10 @@ if [ "${isfcpl}" == "1" ]; then
 	# printf "\n" >> isfcpl.track
 	# rm -f isfcpl.track
     fi
+
+    ln -sf ${start_dir}/isfcpl.track ${run_dir}
     
-    cp -f ${fetish_src_dir}/* ${run_dir}
+    cp -f ${icesheet_src_dir}/* ${run_dir}
     iscpl_nm=.true.
 else
     iscpl_nm=.false.
@@ -173,10 +208,14 @@ do
     leg_almostend_epoch=$(( ${leg_end_epoch} - 43200 ))
     leg_almostend_date=$(date -uR -d@"${leg_almostend_epoch}")
 
+    nextleg_start_epoch=$(( ${leg_end_epoch} + 43200 ))
+    nextleg_start_date=$(date -uR -d@"${nextleg_start_epoch}")
+    
     run_start_date_yyyymmdd=$(date -u -d "${run_start_date}" +%Y%m%d) # FIXME appears unused
     run_end_date_yyyymmdd=$(date -u -d "${run_end_date}" +%Y%m%d) # FIXME appears unused
     leg_start_date_yyyymmdd=$(date -u -d "${leg_start_date}" +%Y%m%d) # FIXME appears unused
     leg_almostend_date_yyyymmdd=$(date -u -d "${leg_almostend_date}" +%Y%m%d) # FIXME appears unused
+    nextleg_start_date_yyyymmdd=$(date -u -d "${nextleg_start_date}" +%Y%m%d) # FIXME appears unused
     leg_beforestart_date_yyyymmdd=$(date -u -d "${leg_beforestart_date}" +%Y%m%d) # FIXME appears unused
 
     # run_start_date_yyyymm="${run_start_date_yyyymmdd::-2}"
@@ -201,20 +240,23 @@ do
 	if (( leg_number == 1 )); then
 
 	    mkdir -p ${archive_dir}/isfcpl
+	    mkdir -p ${archive_dir}/${name_icesheet_model}
 	    rm -f ${start_dir}/isfcpl.track
-	    # Counter for the number of restart since last file exchange with fETISh.
+	    # Counter for the number of restart since last file exchange with the ice sheet model.
 	    cnt_res_isfcpl=0
 
 	    isfcpl_window_days=$(echo "(${n_res_perisfcpl} * ${leg_length_sec}) / 86400" | bc)
-
-	    if (( isfcpl_window_days >= 28 && isfcpl_window_days <= 31 )); then
-		n_month_isfcpl=1
-	    elif (( isfcpl_window_days >= 336 && isfcpl_window_days <= 372 )); then
-		n_month_isfcpl=12
-	    else
-		echo "Can't figure out how many month long is the coupling window."
-		exit 2
-	    fi
+	    isfcpl_d30=$(echo "${isfcpl_window_days} / 30" | bc -l)	    
+	    n_month_isfcpl=$(echo ${isfcpl_d30} | awk '{print int($1+0.5)}')
+	    
+	    # if (( isfcpl_window_days >= 28 && isfcpl_window_days <= 31 )); then
+	    # 	n_month_isfcpl=1
+	    # elif (( isfcpl_window_days >= 336 && isfcpl_window_days <= 372 )); then
+	    # 	n_month_isfcpl=12
+	    # else
+	    # 	echo "Can't figure out how many month long is the coupling window."
+	    # 	exit 2
+	    # fi
 	    
 	    n_month_full_run=$(( $(( 12 * $(( ${run_end_date_yyyymmdd::4} - ${run_start_date_yyyymmdd::4} )) )) + $(( ${run_end_date_yyyymmdd:4:2} - ${run_start_date_yyyymmdd:4:2} )) ))
 	    
@@ -236,13 +278,20 @@ do
 	    init_bathy_file=`basename ${tmp}`
 	    cp -f ${tmp} ${archive_dir}/isfcpl
 	    cp -f ${tmp} ${run_dir}/init_NEMO_bathy.nc
+
+	    date_beg_isfcpl="${run_start_date_yyyymmdd}"
+	    init_geom=1
+	    init_bathy=1
+	    curr_bathy_file=${init_bathy_file}
+	    ln -sf ${run_dir}/${icesheet_init_geom_file} ${run_dir}/${name_icesheet_model}_8km_geometry_curr.nc
+
 	    
 	    printf "# Information for the ice sheet model\n" > ${start_dir}/isfcpl.track
 	    printf "run_name=${exp_name}\n" >> ${start_dir}/isfcpl.track
 	    printf "initial_date=${run_start_date_yyyymmdd}\n" >> ${start_dir}/isfcpl.track
 	    printf "n_month_isfcpl=${n_month_isfcpl}\n" >> ${start_dir}/isfcpl.track
 	    printf "n_isfcpl_window=${n_isfcpl_window}\n" >> ${start_dir}/isfcpl.track
-	    printf "date_beg_isfcpl=YYYYMMDD\n" >> ${start_dir}/isfcpl.track
+	    printf "date_beg_isfcpl=${date_beg_isfcpl}\n" >> ${start_dir}/isfcpl.track
 	    printf "date_end_isfcpl=YYYYMMDD\n\n" >> ${start_dir}/isfcpl.track
 
 	    printf "# Information for NEMO to keep up\n" >> ${start_dir}/isfcpl.track
@@ -251,59 +300,15 @@ do
 	    printf "init_bathy=1\n" >> ${start_dir}/isfcpl.track
 	    printf "curr_bathy_file=${init_bathy_file}\n" >> ${start_dir}/isfcpl.track
 	    
-	    init_geom=1
-	    init_bathy=1
-	    
-	    curr_bathy_file=${init_bathy_file}
 	    
-	    ln -sf ${run_dir}/fETISh_8km_geometry_init.nc ${run_dir}/fETISh_8km_geometry_curr.nc
+
 
 	fi
 	
 	ln -sf ${curr_bathy_file} ${run_dir}/bathy_meter.nc
 	ln -sf ${curr_bathy_file} ${run_dir}/isf_draft_meter.nc
 	
-	if (( $(( ${leg_number} - 1 )) % ${n_res_perisfcpl} == 0 )); then
-	    
-	    date_beg_isfcpl=${leg_start_date_yyyymmdd}
-	    sed -i "s/.*date_beg_isfcpl=.*/date_beg_isfcpl=${date_beg_isfcpl}/" ${start_dir}/isfcpl.track
-	    
-	    if (( leg_number > 1 )); then
-		# leg number at which NEMO is supposed to receive updated geometry from fETISh.
-		# We need to pre-treat fETISh outputs in order to make them readable by NEMO.
-
-		# new fETISh output should be ${run_dir}/fETISh_8km_geometry_curr.nc
-		module purge
-		mlpy
-		module load CDO
-		${pp_fetish_call}
-
-		# Copy (for initial) or move (non initial) previous bathymetry file to archive and link new one to what NEMO will read.
-		new_bathy_file="fETISh_eORCA025-SO_bathymetry_${leg_beforestart_date_yyyymmdd}.nc"
-		mv -f fETISh_new_8km_eORCA025-bathymetry_curr.nc ${new_bathy_file}
-		
-		old_bathy=`readlink -f ${run_dir}/bathy_meter.nc`
-		if [ "${init_bathy}" == 0 ]; then
-		    mv -f ${old_bathy} ${archive_dir}/isfcpl
-		else
-		    init_bathy=0
-		    sed -i "s/^init_bathy=.*$/init_bathy=0/g" ${start_dir}/isfcpl.track
-		    cp -f ${old_bathy} ${archive_dir}/isfcpl
-		fi
-		curr_bathy_file=${new_bathy_file}
-		sed -i "s/.*curr_bathy_file=.*/curr_bathy_file=${curr_bathy_file}/" ${start_dir}/isfcpl.track
-		ln -sf ${new_bathy_file} ${run_dir}/bathy_meter.nc
-		ln -sf ${new_bathy_file} ${run_dir}/isf_draft_meter.nc
-		
-		module purge
-		module load ${module_list:?}
-		export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"${extralibs_list}"
-		
-	    fi
-	fi
-	
     fi
-
     
     # Correct for leap days because NEMO standalone uses no-leap calendar
     if (( leap_years == 0 )); then
@@ -360,7 +365,7 @@ do
     #
 
     if [[ "$@" == *"dbg"* ]]; then
-	echo $HOSTNAME
+	echo $HOSTNAME > ${start_dir}/log
 	sleep 10000000000000
     fi
     
@@ -368,10 +373,17 @@ do
     mpirun -np "${xio_numproc:?}" "${xio_exe_file:?}" : -np "${nem_numproc:?}" "${nem_exe_file:?}"
     time_end=$(date +%s)
 
+    echo "dbg cp made it past mpirun"
+    
     if (( isfcpl == 1 )); then
 
-	module purge
-	module load CDO
+	# NEMO restart index within ice sheet / ocean coupling window
+	cnt_res_isfcpl=$(( $(( ${leg_number} - 1 )) % ${n_res_perisfcpl} ))
+	sed -i "s/.*cnt_res_isfcpl=.*/cnt_res_isfcpl=${cnt_res_isfcpl}/" ${start_dir}/isfcpl.track
+
+	
+	# module purge
+	# module load CDO
 	fmt_res_isfcpl=$(printf "%02d" ${cnt_res_isfcpl})
 	
 	in_stencil="${exp_name}_1m_${leg_start_date_yyyymmdd}_${leg_almostend_date_yyyymmdd}_icesheet"
@@ -390,46 +402,57 @@ do
 	module load ${module_list:?}
 	export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"${extralibs_list}"
 
-	${rebuild_nemo_exe} ${out_stencil} ${xio_numproc}
-	rm -f ${out_stencil}_????.nc
+	echo "dbg cp before rebuild"
 	
+	/bin/bash ${rebuild_nemo_exe} ${out_stencil} ${xio_numproc}
+	rm -f ${out_stencil}_????.nc
 
-	# Counter increase (NEMO restart index within ice sheet / ocean coupling window).
-	cnt_res_isfcpl=$(( ${cnt_res_isfcpl} + 1 ))
-	sed -i "s/.*cnt_res_isfcpl=.*/cnt_res_isfcpl=${cnt_res_isfcpl}/" ${start_dir}/isfcpl.track
+	echo "dbg cp after rebuild"
+
+	
 
 	if (( ${leg_number} % ${n_res_perisfcpl} == 0 )); then
 	    # We have just ended one NEMO leg which closes an ice sheet / ocean coupling window.
 	    date_end_isfcpl=${leg_almostend_date_yyyymmdd}
 	    sed -i "s/.*date_end_isfcpl=.*/date_end_isfcpl=${date_end_isfcpl}/" ${start_dir}/isfcpl.track
 
-	    cp -f ${start_dir}/isfcpl.track ${start_dir}/isfcpl.old
-	    ${rebuild_nemo_exe} mesh_mask ${nem_numproc}
+	    echo "dbg cp before rebuild mesh"
+	    /bin/bash ${rebuild_nemo_exe} mesh_mask ${nem_numproc}
+	    echo "dbg cp after rebuild mesh"
 	    
-	    module purge; module load CDO
+
+	    module purge
+	    ml_pp_ice
+
 	    # Concatenate all icesheet files from all legs contained within this coupling window
 	    tmpfile_eos80="curr_ocean2ice_EOS80.nc"
 	    tmpfile_teos10="curr_ocean2ice_TEOS10.nc"
 	    outfile="${exp_name}_ocean2ice_${date_beg_isfcpl}-${date_end_isfcpl}.nc"
 	    
-	    cdo -O copy "${out_stencil::-2}??.nc" ${tmpfile_teos10}
+	    cdo -O copy ${out_stencil::-2}??.nc ${tmpfile_teos10}
+	    rm -f ${out_stencil::-2}??.nc
 
+	    echo "dbg cp after cdo copy, before pp nemo to fetish"
+	    
+	    
 	    module purge
-	    mlpy
-	    ${pp_nemo_to_fetish_call}
-
+	    ml_pp_ice
+	    ${pp_nemo_to_icesheet_call}
 
 	    mv -f ${tmpfile_eos80} ${outfile}
-	    mv -f mesh_mask.nc ${archive_dir}/isfcpl/mesh_mask_${date_beg_isfcpl}-${date_end_isfcpl}.nc
+	    mv -f mesh_mask.nc ${archive_dir}/isfcpl/${exp_name}_mesh_mask_${date_beg_isfcpl}-${date_end_isfcpl}.nc
+
+	    echo "dbg cp after pp nemo to fetish, before fetish"
 	    
-	    # CALL FETISH
+	    # CALL ICE SHEET MODEL
 	    module purge
-	    cp -f ${start_dir}/isfcpl.track ${run_dir}
-	    module load ${fetish_modules}
-	    ${fetish_call}
+	    module load ${icesheet_modules}
+	    ${icesheet_call}
 
-	    mv -f ${exp_name}_fETISh*.mat ${archive_dir}/isfcpl
-	    ln -sf ${archive_dir}/isfcpl/*.mat ./
+	    echo "dbg cp after fetish"
+	    
+	    find . -type f -name "*.mat" -exec mv -f {} ${archive_dir}/${name_icesheet_model} \;
+	    ln -sf ${archive_dir}/${name_icesheet_model}/*.mat ./
 	    module purge
 
 	    # mv ocean2ice file to arch dir
@@ -437,11 +460,7 @@ do
 	    
 	    new_geom_file="${exp_name}_ice2ocean_${date_end_isfcpl}.nc"
 
-            # module load NCO
-            # ncks -C -v B ${init_fetish_file} -A ${new_geom_file}
-            # module purge
-
-	    old_geom=`readlink -f fETISh_8km_geometry_curr.nc`
+	    old_geom=`readlink -f ${name_icesheet_model}_8km_geometry_curr.nc`
 	    if [ "${init_geom}" == 0 ]; then
 		mv -f ${old_geom} ${archive_dir}/isfcpl
 	    else
@@ -450,16 +469,45 @@ do
 		cp -f ${old_geom} ${archive_dir}/isfcpl
 	    fi
 
-	    ln -sf ${new_geom_file} fETISh_8km_geometry_curr.nc
+	    ln -sf ${new_geom_file} ${name_icesheet_model}_8km_geometry_curr.nc
 	    
-	    cnt_res_isfcpl=0
+	    # leg number at which NEMO is supposed to receive updated geometry from the ice sheet model.
+	    # We need to pre-treat fETISh outputs in order to make them readable by NEMO.
+
+	    # new fETISh output should be ${run_dir}/fETISh_8km_geometry_curr.nc
+	    module purge
+	    ml_pp_ice
+	    ${pp_icesheet_to_nemo_call}
+
+	    # Copy (for initial) or move (non initial) previous bathymetry file to archive and link new one to what NEMO will read.
+	    new_bathy_file="${name_icesheet_model}_eORCA025-SO_bathymetry_${date_end_isfcpl}.nc"
+	    mv -f ${name_icesheet_model}_new_8km_eORCA025-bathymetry_curr.nc ${new_bathy_file}
+		
+	    old_bathy=`readlink -f ${run_dir}/bathy_meter.nc`
+	    if [ "${init_bathy}" == 0 ]; then
+		mv -f ${old_bathy} ${archive_dir}/isfcpl
+	    else
+		init_bathy=0
+		sed -i "s/^init_bathy=.*$/init_bathy=0/g" ${start_dir}/isfcpl.track
+		cp -f ${old_bathy} ${archive_dir}/isfcpl
+	    fi
+	    curr_bathy_file=${new_bathy_file}
+	    sed -i "s/.*curr_bathy_file=.*/curr_bathy_file=${curr_bathy_file}/" ${start_dir}/isfcpl.track
+	    
+	    ln -sf ${new_bathy_file} ${run_dir}/bathy_meter.nc
+	    ln -sf ${new_bathy_file} ${run_dir}/isf_draft_meter.nc
+		
+	    module purge
+	    module load ${module_list:?}
+	    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"${extralibs_list}"
 
+	    
 	    printf "# Information for the ice sheet model\n" > ${start_dir}/isfcpl.track
 	    printf "run_name=${exp_name}\n" >> ${start_dir}/isfcpl.track
 	    printf "initial_date=${run_start_date_yyyymmdd}\n" >> ${start_dir}/isfcpl.track
 	    printf "n_month_isfcpl=${n_month_isfcpl}\n" >> ${start_dir}/isfcpl.track
 	    printf "n_isfcpl_window=${n_isfcpl_window}\n" >> ${start_dir}/isfcpl.track
-	    printf "date_beg_isfcpl=YYYYMMDD\n" >> ${start_dir}/isfcpl.track
+	    printf "date_beg_isfcpl=${nextleg_start_date_yyyymmdd}\n" >> ${start_dir}/isfcpl.track
 	    printf "date_end_isfcpl=YYYYMMDD\n\n" >> ${start_dir}/isfcpl.track
 	    printf "# Information for NEMO to keep up\n" >> ${start_dir}/isfcpl.track	    
 	    printf "cnt_res_isfcpl=0\n" >> ${start_dir}/isfcpl.track