source: trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh @ 705

Last change on this file since 705 was 705, checked in by sdipsl, 12 years ago
  • a little enhancement on mercure regarding the pack (mv instead of cp)
  • some cosmetics
  • Property svn:keywords set to Revision Author Date
File size: 71.0 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip, Arnaud Caubel
5# Contact: Arnaud.Caubel__at__lsce.ipsl.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14#=========================================================
15# The documentation of this file can be automatically generated
16# if you use the prefix #D- for comments to be extracted.
17# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
18#=========================================================
19
20#D-#==================================================
21#D-LibIGCM_sys for Titane
22#D-#==================================================
23#D-
24#D- This ksh library if a layer under some usefull
25#D-environment variables and shell commands.
26#D-All those definitions depend on host particularities.
27#D-It manages a stack mechanism and test validity of operations.
28#D-All function described bellow must be prefixed by IGCM_sys.
29
30#====================================================
31# libIGCM_sys PARAMETERS
32#====================================================
33
34#====================================================
35# set DEBUG_sys to true to output calls of function
36typeset -r DEBUG_sys=${DEBUG_sys:=true}
37
38#====================================================
39# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
40typeset -r DRYRUN=${DRYRUN:=0}
41
42# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
43# -------------------------------------------------------------------------------------
44# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
45# |          |  Cp/Exe param files |            |  Chmod  |                           |
46# |          |      Qsub           |            |         |                           |
47# -------------------------------------------------------------------------------------
48# |    0     |       yes           |    yes     |  yes    |      yes                  |
49# -------------------------------------------------------------------------------------
50# |    1     |       yes           |    yes     |  yes    |      no                   |
51# -------------------------------------------------------------------------------------
52# |    2     |       yes           |    yes     |  no     |      no                   |
53# -------------------------------------------------------------------------------------
54# |    3     |       yes           |    no      |  no     |      no                   |
55# -------------------------------------------------------------------------------------
56
57#=====================================================
58# Global Variables :
59#=====================================================
60# Language : "fr" or "en"
61typeset -r MYLANG="fr"
62
63#=====================================================
64# Host and user names
65# $hostname ou hostname
66typeset  HOST=${HOST:=$( hostname )}
67# $username ou whoami
68typeset  LOGIN=${LOGIN:=$( whoami )}
69# $hostname of the MASTER job
70typeset MASTER=titane
71
72#D-
73#D-#==================================================
74#D-Program used in libIGCM
75#D-#==================================================
76
77# rsync with path
78typeset -r RSYNC=/usr/bin/rsync
79# RSYNC_opt args to rsync
80typeset -r RSYNC_opt="-va"
81# ie storage filesystem
82typeset -r STOREHOST=${MASTER}
83
84#====================================================
85# Source default environment
86#====================================================
87. /etc/profile
88
89#====================================================
90# Set environment tools (ferret, nco, cdo)
91#====================================================
92. /home/cont003/p86ipsl/.atlas_env_titane_ksh
93if ( [ X${LSB_QUEUE} = Xmono ] || [ X${LSB_QUEUE} = Xmonoext ] ) ; then
94  module switch nco/3.9.4 nco/3.9.4_netcdf4
95fi
96
97#====================================================
98# Specific for ocean additionnal diagnostic
99export FER_GO="$FER_GO /home/cont003/p86denv/IGCM_POST_UTIL/JNL /home/cont003/p86denv/GRAF /home/cont003/p86denv/GRAF/GO"
100export FER_PALETTE="$FER_PALETTE /home/cont003/p86denv/GRAF/PALET"
101
102#====================================================
103# Host specific DIRECTORIES
104#====================================================
105
106# ============ CESIUM START ============ #
107
108#====================================================
109#- Mirror libIGCM from titane to cesium if needed
110#ROOTSYS=$( echo ${libIGCM} | gawk -F"/" '{print $3}' )
111#if [ ! ${ROOTSYS} = "home" ] ; then
112#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true}
113#else
114#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
115#fi
116
117#====================================================
118#- libIGCM_POST
119#if ( ${MirrorlibIGCM} ) ; then
120#  PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" )
121#  typeset -r libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM
122#else
123#  typeset -r libIGCM_POST=${libIGCM}
124#fi
125
126# ============ CESIUM  END  ============ #
127
128#====================================================
129#- MirrorlibIGCM for frontend
130typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
131
132#====================================================
133#- libIGCM_POST for frontend
134typeset -r libIGCM_POST=${libIGCM}
135
136#====================================================
137#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
138typeset -r R_EXE="${MODIPSL}/bin"
139
140#====================================================
141#- SUBMIT_DIR : submission dir
142typeset SUBMIT_DIR=${SUBMIT_DIR:=${LS_SUBCWD}}
143
144#====================================================
145#- ARCHIVE (dedicated to large files)
146typeset -r ARCHIVE=${CCCSTOREDIR}
147
148#- ARCHIVE (dedicated to small/medium files)
149typeset -r STORAGE=${CCCWORKDIR}
150
151#====================================================
152#- IN
153typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM}
154typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/dmnfs/cont003/p24data}
155
156#====================================================
157#- R_OUT
158typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
159
160#====================================================
161#- R_FIG (hosting figures : monitoring and atlas, and/or small files)
162typeset -r R_FIG=${STORAGE}/IGCM_OUT
163
164#====================================================
165#- R_BUF (ONLY FOR double copy an scratch)
166typeset -r R_BUF=${SCRATCHDIR}/IGCM_OUT
167
168#====================================================
169#- BIG_DIR : BIG_DIR to store files waiting for rebuild
170typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD}
171
172#====================================================
173#- OUT_POST
174typeset -r R_OUT_POST=${SCRATCHDIR}/IGCM_OUT
175
176#====================================================
177#- RUN_DIR_PATH : Temporary working directory (=> TMP)
178if ( [ ! X${LSB_QUEUE} = Xmono ] && [ ! X${LSB_QUEUE} = Xmonoext ] ) ; then
179  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/RUN_DIR/${LSB_JOBID}}
180else
181  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/TMPDIR_IGCM/${LSB_JOBID}}
182fi
183
184#====================================================
185#- HOST_MPIRUN_COMMAND
186typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time mpirun"}
187
188#====================================================
189#- Max number of arguments passed to nco operator or demigration command
190UNIX_MAX_LIMIT=360
191
192#====================================================
193#- set PackDefault true on titane
194PackDefault=true
195
196#====================================================
197#- Number of core per node (max number of OpenMP task)
198NUM_COREPERNODE=8
199
200#====================================================
201#- Default number of MPI task for IPSL coupled model
202#- required for backward compatibility
203#-
204DEFAULT_NUM_PROC_OCE=5
205DEFAULT_NUM_PROC_CPL=1
206(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
207DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
208
209
210#D-#==================================================
211#D-function IGCM_sys_RshMaster
212#D-* Purpose: Connection to frontend machine.
213#D-* Examples:
214#D-
215function IGCM_sys_RshMaster {
216  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
217  /bin/ksh <<-EOF
218    export libIGCM=${libIGCM}
219    export DEBUG_debug=${DEBUG_debug}
220    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
221    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
222    ${@}
223EOF
224  if [ $? -gt 0 ] ; then
225    echo "IGCM_sys_RshMaster : erreur."
226    IGCM_debug_Exit "IGCM_sys_RshMaster"
227  fi
228  IGCM_debug_PopStack "IGCM_sys_RshMaster"
229}
230
231#D-#==================================================
232#D-function IGCM_sys_RshArchive
233#D-* Purpose: Archive rsh command
234#D-* Examples:
235#D-
236function IGCM_sys_RshArchive {
237  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
238  /bin/ksh <<-EOF
239    ${@}
240EOF
241  if [ $? -gt 0 ] ; then
242    echo "IGCM_sys_RshArchive : erreur."
243    IGCM_debug_Exit "IGCM_sys_RshArchive"
244  fi
245  IGCM_debug_PopStack "IGCM_sys_RshArchive"
246}
247
248#D-#==================================================
249#D-function IGCM_sys_RshPost
250#D-* Purpose: Post-process rsh command
251#D-* Examples:
252#D-
253function IGCM_sys_RshPost {
254  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
255  if ( $DEBUG_sys ) ; then
256    echo "IGCM_sys_RshPost :" $@
257  fi
258
259  #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL
260  #cat tmp_IGCM_sys_RshPost_$$
261  # keep standard input (stdin) for the loop onto temporary file
262  cat >tmp_IGCM_sys_RshPost_$$
263
264# ============ FRONTEND START ============ #
265
266  /bin/ksh <tmp_IGCM_sys_RshPost_$$
267  if [ $? -gt 0 ] ; then
268    echo "IGCM_sys_RshPost : erreur."
269    IGCM_debug_Exit "IGCM_sys_RshPost"
270  fi
271  # delete temporary file
272  \rm tmp_IGCM_sys_RshPost_$$
273
274# ============ FRONTEND  END  ============ #
275
276# ============ CESIUM START ============ #
277#  typeset NB_ESSAI DELAI status i
278#  if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then
279#    #little hack so that rebuild submission is done on titane not an cesium
280#
281#    libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' )
282#    POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' )
283#    sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt
284#    sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$
285#    sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt
286#    sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$
287#    \mv tmp.txt tmp_IGCM_sys_RshPost_$$
288#
289#    echo cat tmp_IGCM_sys_RshPost_$$ AFTER
290#    cat tmp_IGCM_sys_RshPost_$$
291#
292#    /bin/ksh <tmp_IGCM_sys_RshPost_$$
293#    if [ $? -gt 0 ] ; then
294#      echo "IGCM_sys_RshPost : erreur."
295#      IGCM_debug_Exit "IGCM_sys_RshPost"
296#    fi
297#    # delete temporary file
298#    \rm tmp_IGCM_sys_RshPost_$$
299#
300#  else
301#    # number of tentative
302#    NB_ESSAI=10
303#    # time delay between tentative
304#    DELAI=10
305#    i=0
306#    while [ $i -ne $NB_ESSAI ] ; do
307#      ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$
308#      status=$?
309#      if [ ${status} -ne 0 ];
310#      then
311#       sleep $DELAI
312#      else
313#       break
314#      fi
315#      let i=$i+1
316#    done
317#    # delete temporary file
318#    \rm tmp_IGCM_sys_RshPost_$$
319#
320#    if [ ${status} -gt 0 ] ; then
321#      echo "IGCM_sys_RshPost : erreur."
322#      IGCM_debug_Exit "IGCM_sys_RshPost"
323#    fi
324#  fi
325
326# ============ CESIUM  END  ============ #
327
328  IGCM_debug_PopStack "IGCM_sys_RshPost"
329}
330
331#D-#==================================================
332#D-function IGCM_sys_SendMail
333#D-* Purpose: Send mail when simulation is over
334#D-* Examples:
335#D-
336function IGCM_sys_SendMail {
337  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
338  if ( $DEBUG_sys ) ; then
339    echo "IGCM_sys_SendMail :" $@
340  fi
341
342  if ( ${ExitFlag} ) ; then
343    status=failed
344  else
345    status=completed
346  fi
347
348    cat  << END_MAIL > job_end.mail
349Dear ${LOGIN},
350
351  Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
352  Job started : ${DateBegin}
353  Job ended   : ${DateEnd}
354  Output files are available in ${R_SAVE}
355  Files to be rebuild are temporarily available in ${REBUILD_DIR}
356  Pre-packed files are temporarily available in ${R_BUFR}
357  Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
358END_MAIL
359
360    if [ ! -z ${config_UserChoices_MailName} ] ; then
361        mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < job_end.mail
362    elif [ -f ~/.forward ] ; then
363        mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < job_end.mail
364    fi
365    sleep 10
366    rm -f job_end.mail
367
368  if [ $? -gt 0 ] ; then
369    echo "IGCM_sys_SendMail : erreur."
370    IGCM_debug_Exit "IGCM_sys_SendMail"
371  fi
372  IGCM_debug_PopStack "IGCM_sys_SendMail"
373}
374
375#D-#==================================================
376#D-function IGCM_sys_Mkdir
377#D-* Purpose: Master locale mkdir command
378#D-* Examples:
379#D-
380function IGCM_sys_Mkdir {
381  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
382  if ( $DEBUG_sys ) ; then
383    echo "IGCM_sys_Mkdir :" $@
384  fi
385  if [ ! -d ${1} ]; then
386    \mkdir -p $1
387    if [ $? -gt 0 ] ; then
388      echo "IGCM_sys_Mkdir : erreur."
389      IGCM_debug_Exit "IGCM_sys_Mkdir"
390    fi
391  fi
392  # vérification :
393  if [ ! -d ${1} ] ; then
394    echo "IGCM_sys_Mkdir : erreur."
395    IGCM_debug_Exit "IGCM_sys_Mkdir"
396  fi
397  IGCM_debug_PopStack "IGCM_sys_Mkdir"
398}
399
400#D-#==================================================
401#D-function IGCM_sys_MkdirArchive
402#D-* Purpose: Mkdir on Archive
403#D-* Examples:
404#D-
405function IGCM_sys_MkdirArchive {
406  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
407  if ( $DEBUG_sys ) ; then
408    echo "IGCM_sys_MkdirArchive :" $@
409  fi
410  #- creation de repertoire sur le serveur fichier
411  if [ ! -d ${1} ]; then
412    \mkdir -p $1
413    if [ $? -gt 0 ] ; then
414      echo "IGCM_sys_MkdirArchive : erreur."
415      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
416    fi
417  fi
418  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
419}
420
421#D-#==================================================
422#D-function IGCM_sys_MkdirWork
423#D-* Purpose: Mkdir on Work
424#D-* Examples:
425#D-
426function IGCM_sys_MkdirWork {
427  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
428  if ( $DEBUG_sys ) ; then
429    echo "IGCM_sys_MkdirWork :" $@
430  fi
431  #- creation de repertoire sur le serveur fichier
432  if [ ! -d ${1} ]; then
433    \mkdir -p $1
434    if [ $? -gt 0 ] ; then
435      echo "IGCM_sys_MkdirWork : erreur."
436      IGCM_debug_Exit "IGCM_sys_MkdirWork"
437    fi
438  fi
439  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
440}
441
442#D-#==================================================
443#D-function IGCM_sys_Cd
444#D-* Purpose: master cd command
445#D-* Examples:
446#D-
447function IGCM_sys_Cd {
448  IGCM_debug_PushStack "IGCM_sys_Cd" $@
449  if ( $DEBUG_sys ) ; then
450    echo "IGCM_sys_Cd :" $@
451  fi
452  \cd $1
453  if [ $? -gt 0 ] ; then
454    echo "IGCM_sys_Cd : erreur."
455    IGCM_debug_Exit "IGCM_sys_Cd"
456  fi
457  IGCM_debug_PopStack "IGCM_sys_Cd"
458}
459
460#D-#==================================================
461#D-function IGCM_sys_Chmod
462#D-* Purpose: Chmod
463#D-* Examples:
464#D-
465function IGCM_sys_Chmod {
466  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
467  if ( $DEBUG_sys ) ; then
468    echo "IGCM_sys_Chmod :" $@
469  fi
470  if [ $DRYRUN -le 1 ]; then
471    \chmod $@
472    if [ $? -gt 0 ] ; then
473      echo "IGCM_sys_Chmod : erreur."
474      IGCM_debug_Exit "IGCM_sys_Chmod"
475    fi
476  else
477    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
478  fi
479  IGCM_debug_PopStack "IGCM_sys_Chmod"
480}
481
482#D-#==================================================
483#D-function IGCM_sys_FileSize
484#D-* Purpose: Filesize
485#D-* Examples:
486#D-
487function IGCM_sys_FileSize {
488  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
489
490  typeset sizeF
491  set +A sizeF -- $( ls -la ${1} )
492  if [ $? -gt 0 ] ; then
493    IGCM_debug_Exit "IGCM_sys_FileSize"
494  fi
495  eval ${2}=${sizeF[4]}
496
497  IGCM_debug_PopStack "IGCM_sys_FileSize"
498}
499
500#D-#==================================================
501#D-function IGCM_sys_TestDir
502#D-* Purpose: Test Directory that must exists
503#D-* Examples:
504#D-
505function IGCM_sys_TestDir {
506  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
507  if ( $DEBUG_sys ) ; then
508    echo "IGCM_sys_TestDir :" $@
509  fi
510  typeset ExistFlag
511  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
512  IGCM_debug_PopStack "IGCM_sys_TestDir"
513
514  return ${ExistFlag}
515}
516
517#D-#==================================================
518#D-function IGCM_sys_TestDirArchive
519#D-* Purpose: Test Directory that must exists on Archive
520#D-* Examples:
521#D-
522function IGCM_sys_TestDirArchive {
523  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
524  if ( $DEBUG_sys ) ; then
525    echo "IGCM_sys_TestDirArchive :" $@
526  fi
527  typeset ExistFlag
528  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
529  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
530
531  return ${ExistFlag}
532}
533
534#D-#==================================================
535#D-function IGCM_sys_IsFileArchived
536#D-* Purpose: Test file that must NOT EXISTS on Archive
537#D-* Examples:
538#D-
539function IGCM_sys_IsFileArchived {
540  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
541  if ( $DEBUG_sys ) ; then
542    echo "IGCM_sys_IsFileArchived :" $@
543  fi
544  typeset IsArchivedFlag
545  IsArchivedFlag=$( [ X$( echo $1 | grep ^\/ccc\/store ) != X ] && echo 0 || echo 1 )
546  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
547
548  return ${IsArchivedFlag}
549}
550
551#D-#==================================================
552#D-function IGCM_sys_TestFileArchive
553#D-* Purpose: Test file that must NOT EXISTS on Archive
554#D-* Examples:
555#D-
556function IGCM_sys_TestFileArchive {
557  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
558  typeset ExistFlag
559  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
560  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
561
562  return ${ExistFlag}
563}
564
565#D-#==================================================
566#D-function IGCM_sys_TestFileBuffer
567#D-* Purpose: Test file that must NOT EXISTS on Buffer
568#D-* Examples:
569#D-
570function IGCM_sys_TestFileBuffer {
571  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
572  typeset ExistFlag
573  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
574  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
575
576  return ${ExistFlag}
577}
578
579#D-#==================================================
580#D-function IGCM_sys_CountFileArchive
581#D-* Purpose: Count files on Archive filesystem
582#D-* Examples:
583#D-
584function IGCM_sys_CountFileArchive {
585  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
586  ls ${@} 2>/dev/null | wc -l
587  if [ $? -gt 0 ] ; then
588    echo "IGCM_sys_CountFileArchive : erreur."
589  fi
590  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
591}
592
593#D-#==================================================
594#D-function IGCM_sys_CountFileBuffer
595#D-* Purpose: Count files on Scratch filesystem
596#D-* Examples:
597#D-
598function IGCM_sys_CountFileBuffer {
599  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
600  ls ${@} 2>/dev/null | wc -l
601  if [ $? -gt 0 ] ; then
602    echo "IGCM_sys_CountFileBuffer : erreur."
603  fi
604  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
605}
606
607#D-#==================================================
608#D-function IGCM_sys_Tree
609#D-* Purpose: Tree directories with files on ${ARCHIVE}
610#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
611#D-
612function IGCM_sys_Tree {
613  IGCM_debug_PushStack "IGCM_sys_Tree" $@
614  if ( $DEBUG_sys ) ; then
615    echo "IGCM_sys_Tree :" $@
616  fi
617
618  \ls -lR ${@}
619
620  IGCM_debug_PopStack "IGCM_sys_Tree"
621}
622
623#D-#==================================================
624#D-function IGCM_sys_Tar
625#D-* Purpose: master tar command
626#D-* Examples:
627#D-
628function IGCM_sys_Tar {
629  IGCM_debug_PushStack "IGCM_sys_Tar" $@
630  if ( $DEBUG_sys ) ; then
631    echo "IGCM_sys_Tar :" $@
632  fi
633  \tar cf $@
634  if [ $? -gt 0 ] ; then
635    echo "IGCM_sys_Tar : erreur."
636    IGCM_debug_Exit "IGCM_sys_Tar"
637  fi
638  IGCM_debug_PopStack "IGCM_sys_Tar"
639}
640
641#D-#==================================================
642#D-function IGCM_sys_UnTar
643#D-* Purpose: master un-tar command
644#D-* Examples:
645#D-
646function IGCM_sys_UnTar {
647  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
648  if ( $DEBUG_sys ) ; then
649    echo "IGCM_sys_UnTar :" $@
650  fi
651  \tar xvf $1
652  if [ $? -gt 0 ] ; then
653    echo "IGCM_sys_UnTar : erreur."
654    IGCM_debug_Exit "IGCM_sys_UnTar"
655  fi
656  IGCM_debug_PopStack "IGCM_sys_UnTar"
657}
658
659#D-#==================================================
660#D-function IGCM_sys_Qsub
661#D-* Purpose: Qsub new job
662#D-* Examples:
663#D-
664function IGCM_sys_Qsub {
665  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
666  if ( $DEBUG_sys ) ; then
667    echo "IGCM_sys_Qsub :" $@
668  fi
669  typeset options
670  if [ ${config_UserChoices_JobName}.${CumulPeriod} = "." ] ; then
671    options=" -o ${Script_Output} -e ${Script_Output}"
672  else
673    options=" -o ${Script_Output} -e ${Script_Output} -r ${config_UserChoices_JobName}.${CumulPeriod}"
674  fi
675
676  /usr/local/bin/ccc_msub ${options} < $1
677  if [ $? -gt 0 ] ; then
678    echo "IGCM_sys_Qsub : erreur ${options} $1"
679    IGCM_debug_Exit "IGCM_sys_Qsub"
680  fi
681  IGCM_debug_PopStack "IGCM_sys_Qsub"
682}
683
684#D-#==================================================
685#D-function IGCM_sys_QsubPost
686#D-* Purpose: Qsub new job on scalaire
687#D-* Examples:
688#D-
689function IGCM_sys_QsubPost {
690  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
691  if ( $DEBUG_sys ) ; then
692    echo "IGCM_sys_QsubPost :" $@
693  fi
694
695  # Need to export listVarEnv for cesium
696  # NO Need to export listVarEnv for titane
697# ============ FRONTEND START ============ #
698
699  /usr/local/bin/ccc_msub -p ${BRIDGE_MSUB_PROJECT} -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out ${libIGCM_POST}/$1.job
700
701# ============ FRONTEND  END  ============ #
702
703# ============ CESIUM START ============ #
704#  typeset NB_ESSAI DELAI status i
705#  # number of tentative
706#  NB_ESSAI=10
707#  # time delay between tentative
708#  DELAI=10
709#  (( i = 0 ))
710#  while [ $i -lt $NB_ESSAI ] ; do
711#    /usr/local/bin/ccc_msub -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.e.out -E "-v ${listVarEnv}" ${libIGCM_POST}/$1.job
712#    status=$?
713#    if [ ${status} -gt 0 ]; then
714#      sleep $DELAI
715#    else
716#      break
717#    fi
718#    (( i = i + 1 ))
719#  done
720# ============ CESIUM  END  ============ #
721
722  if [ $? -gt 0 ] ; then
723    echo "IGCM_sys_QsubPost : erreur " $@
724    IGCM_debug_Exit "IGCM_sys_QsubPost"
725  fi
726  IGCM_debug_PopStack "IGCM_sys_QsubPost"
727}
728
729#D-*************************
730#D- File transfer functions
731#D-*************************
732#D-
733
734#D-#==================================================
735#D-function IGCM_sys_Rsync_out
736#D-* Purpose: treat return val of rsync
737#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
738#D-  Error values and explanations can depend on your system version.
739function IGCM_sys_Rsync_out {
740  RET=$1
741  if [ ! $RET ] ; then
742    echo "rsync error !"
743  fi
744
745  if [ $MYLANG = "fr" ]; then
746    case $RET in
747    0)  return ;;
748    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
749      echo "Erreur de syntaxe ou d'utilisation."
750      return;;
751    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
752      echo "Incompatibilité de protocole."
753      return;;
754    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
755      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
756      echo "répertoires"
757      return;;
758    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
759      echo "Action demandée non supportée : une tentative de manipulation de"
760      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
761      echo "été faite ; ou une option qui est supportée par le  client  mais"
762      echo "pas par le serveur a été spécifiée."
763      return;;
764    10) echo "Erreur de rsync ; RERR_SOCKETIO"
765      echo "Erreur dans le socket d'entrée sortie"
766      return;;
767    11) echo "Erreur de rsync ; RERR_FILEIO"
768      echo "Erreur d'entrée sortie fichier"
769      return;;
770    12) echo "Erreur de rsync ; RERR_STREAMIO"
771      echo "Erreur dans flux de donnée du protocole rsync"
772      return;;
773    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
774      echo "Erreur avec les diagnostics du programme"
775      return;;
776    14) echo "Erreur de rsync ; RERR_IPC"
777      echo "Erreur dans le code IPC"
778      return;;
779    20) echo "Erreur de rsync ; RERR_SIGNAL"
780      echo "SIGUSR1 ou SIGINT reçu"
781      return;;
782    21) echo "Erreur de rsync ; RERR_WAITCHILD"
783      echo "Une erreur retournée par waitpid()"
784      return;;
785    22) echo "Erreur de rsync ; RERR_MALLOC"
786      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
787      return;;
788    23) echo ""
789      echo "Erreur fichier inexistant"
790      return;;
791    30) echo "Erreur de rsync ; RERR_TIMEOUT"
792      echo "Temps d'attente écoulé dans l'envoi/réception de données"
793      return;;
794    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
795      return;;
796    esac
797  elif [ $MYLANG = "en" ] ; then
798    case $RET in
799    0)  return;;
800    1)  echo "rsync error : Syntax or usage error "
801      return;;
802    2)  echo "rsync error : Protocol incompatibility "
803      return;;
804    3)  echo "rsync error : Errors selecting input/output files, dirs"
805      return;;
806    4)  echo "rsync error : Requested action not supported: an attempt"
807      echo "was made to manipulate 64-bit files on a platform that cannot support"
808      echo "them; or an option was specified that is supported by the client and"
809      echo "not by the server."
810      return;;
811    5)  echo "rsync error : Error starting client-server protocol"
812      return;;
813    10) echo "rsync error : Error in socket I/O "
814      return;;
815    11) echo "rsync error : Error in file I/O "
816      return;;
817    12) echo "rsync error : Error in rsync protocol data stream "
818      return;;
819    13) echo "rsync error : Errors with program diagnostics "
820      return;;
821    14) echo "rsync error : Error in IPC code "
822      return;;
823    20) echo "rsync error : Received SIGUSR1 or SIGINT "
824      return;;
825    21) echo "rsync error : Some error returned by waitpid() "
826      return;;
827    22) echo "rsync error : Error allocating core memory buffers "
828      return;;
829    23) echo "rsync error : Partial transfer due to error"
830      return;;
831    24) echo "rsync error : Partial transfer due to vanished source files"
832      return;;
833    30) echo "rsync error : Timeout in data send/receive "
834      return;;
835    *)  echo "rsync error : return code of rsync unknown :" $RET
836      return;;
837    esac
838  else
839    echo "unknown language $MYLANG."
840    return
841  fi
842}
843
844#D-#==================================================
845#D-function IGCM_sys_Miror_libIGCM
846#D-* Purpose: Mirror libIGCM PATH and lib to cesium
847#D-* Examples:
848#D-
849function IGCM_sys_Mirror_libIGCM {
850  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
851  if ( $DEBUG_sys ) ; then
852    echo "IGCM_sys_Mirror_libIGCM"
853  fi
854
855  typeset RET DEST
856
857  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
858
859  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
860  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
861  RET=$?
862
863  if [ ${RET} -gt 0 ] ; then
864    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium."
865    cat out_rsync
866  fi
867  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
868}
869
870#D-#==================================================
871#D-function IGCM_sys_Cp
872#D-* Purpose: generic cp
873#D-* Examples:
874#D-
875function IGCM_sys_Cp {
876  IGCM_debug_PushStack "IGCM_sys_Cp" $@
877  if ( $DEBUG_sys ) ; then
878    echo "IGCM_sys_Cp :" $@
879  fi
880
881  typeset RET
882
883  echo cp $@ > out_rsync 2>&1
884  \cp $@ >> out_rsync 2>&1
885  RET=$?
886
887  if [ ${RET} -gt 0 ] ; then
888    echo "IGCM_sys_Cp : error."
889    cat out_rsync
890    IGCM_debug_Exit "IGCM_sys_Cp"
891  else
892    \rm out_rsync
893  fi
894  IGCM_debug_PopStack "IGCM_sys_Cp"
895}
896
897#D-#==================================================
898#D-function IGCM_sys_Rm
899#D-* Purpose: generic rm
900#D-* Examples:
901#D-
902function IGCM_sys_Rm {
903  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
904  if ( $DEBUG_sys ) ; then
905    echo "IGCM_sys_Rm :" $@
906  fi
907
908  typeset RET
909
910  echo rm $@ > out_rsync 2>&1
911  \rm $@ >> out_rsync 2>&1
912  RET=$?
913
914  if [ ${RET} -gt 0 ] ; then
915    echo "IGCM_sys_Rm : error."
916    cat out_rsync
917    IGCM_debug_Exit "IGCM_sys_Rm"
918  else
919    \rm out_rsync
920  fi
921  IGCM_debug_PopStack "IGCM_sys_Rm"
922}
923
924#D-#==================================================
925#D-function IGCM_sys_RmRunDir
926#D-* Purpose: rm tmpdir (dummy function most of the time batch
927#D-                      scheduler will do the job)
928#D-* Examples:
929#D-
930function IGCM_sys_RmRunDir {
931  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
932  if ( $DEBUG_sys ) ; then
933    echo "IGCM_sys_RmRunDir :" $@
934  fi
935
936  typeset RET
937
938  echo rm $@ > out_rsync 2>&1
939  \rm $@ >> out_rsync 2>&1
940  RET=$?
941
942  if [ ${RET} -gt 0 ] ; then
943    echo "IGCM_sys_RmRunDir : error."
944    cat out_rsync
945    IGCM_debug_Exit "IGCM_sys_RmRunDir"
946  else
947    \rm out_rsync
948  fi
949  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
950}
951
952#D-#==================================================
953#D-function IGCM_sys_Mv
954#D-* Purpose: generic move
955#D-* Examples:
956#D-
957function IGCM_sys_Mv {
958  IGCM_debug_PushStack "IGCM_sys_Mv" $@
959  if ( $DEBUG_sys ) ; then
960    echo "IGCM_sys_Mv :" $@
961  fi
962
963  if [ $DRYRUN = 0 ]; then
964
965    typeset RET
966
967    echo mv $@ > out_rsync 2>&1
968    \mv $@ >> out_rsync 2>&1
969    RET=$?
970
971    if [ ${RET} -gt 0 ] ; then
972      echo "IGCM_sys_Mv : error in mv."
973      cat out_rsync
974      IGCM_debug_Exit "IGCM_sys_Mv"
975    else
976      \rm out_rsync
977    fi
978  else
979    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
980  fi
981
982  IGCM_debug_PopStack "IGCM_sys_Mv"
983}
984
985#D-#==================================================
986#D-function IGCM_sys_Put_Dir
987#D-* Purpose: Copy a complete directory on $(ARCHIVE)
988#D-* Examples:
989#D-
990function IGCM_sys_Put_Dir {
991  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
992  if ( $DEBUG_sys ) ; then
993    echo "IGCM_sys_Put_Dir :" $@
994  fi
995  if [ $DRYRUN = 0 ]; then
996    if [ ! -d ${1} ] ; then
997      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
998      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
999      return
1000    fi
1001
1002    typeset RET
1003
1004    # Only if we use rsync
1005    #IGCM_sys_TestDirArchive $( dirname $2 )
1006    #
1007    #USUAL WAY
1008    \cp -r $1 $2 > out_rsync 2>&1
1009    RET=$?
1010
1011    if [ ${RET} -gt 0 ] ; then
1012      echo "IGCM_sys_Put_Dir : error."
1013      cat out_rsync
1014      IGCM_debug_Exit "IGCM_sys_Put_Dir"
1015    else
1016      \rm out_rsync
1017    fi
1018  else
1019    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1020  fi
1021  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
1022}
1023
1024#D-#==================================================
1025#D-function IGCM_sys_Get_Dir
1026#D-* Purpose: Copy a complete directory from ${ARCHIVE}
1027#D-* Examples:
1028#D-
1029function IGCM_sys_Get_Dir {
1030  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
1031  if ( $DEBUG_sys ) ; then
1032    echo "IGCM_sys_Get_Dir :" $@
1033  fi
1034  if [ $DRYRUN = 0 ]; then
1035#    if [ ! -d ${1} ] ; then
1036#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
1037#      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
1038#      return
1039#    fi
1040
1041    typeset RET
1042
1043    # Only if we use rsync
1044    #IGCM_sys_TestDirArchive $( dirname $2 )
1045    #
1046    # USUAL WAY
1047    # add dmfind/dmget (to demigrate all offline files) :
1048    #dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget
1049    \cp -r $1 $2 > out_rsync 2>&1
1050    RET=$?
1051
1052    if [ ${RET} -gt 0 ] ; then
1053      echo "IGCM_sys_Get_Dir : error."
1054      cat out_rsync
1055      IGCM_debug_Exit "IGCM_sys_Get_Dir"
1056    else
1057      \rm out_rsync
1058    fi
1059  else
1060    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1061  fi
1062  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
1063}
1064
1065#D-#==================================================
1066#D-function IGCM_sys_Get_Master
1067#D-* Purpose: Copy a complete directory from MASTER filesystem
1068#D-* Examples:
1069#D-
1070function IGCM_sys_Get_Master {
1071  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
1072  if ( $DEBUG_sys ) ; then
1073    echo "IGCM_sys_Get_Master :" $@
1074  fi
1075  if [ $DRYRUN = 0 ]; then
1076    if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then
1077      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
1078      IGCM_debug_PopStack "IGCM_sys_Get_Master"
1079      return
1080    fi
1081
1082    typeset RET
1083
1084    #USUAL WAY
1085    \cp -rL $1 $2 > out_rsync 2>&1
1086    RET=$?
1087
1088    if [ ${RET} -gt 0 ] ; then
1089      echo "IGCM_sys_Get_Master : error."
1090      cat out_rsync
1091      IGCM_debug_Exit "IGCM_sys_Get_Master"
1092    else
1093      \rm out_rsync
1094    fi
1095  else
1096    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1097  fi
1098  IGCM_debug_PopStack "IGCM_sys_Get_Master"
1099}
1100
1101#====================================================
1102#- Call IGCM_sys_Mirror_libIGCM now !
1103if ( $MirrorlibIGCM ) ; then
1104  IGCM_sys_Mirror_libIGCM
1105fi
1106
1107#D-#==================================================
1108#D-function IGCM_sys_Put_Rest
1109#D-* Purpose: Put computied restarts on ${ARCHIVE}.
1110#D-           File and target directory must exist.
1111#D-* Examples:
1112#D-
1113function IGCM_sys_Put_Rest {
1114  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
1115  if ( $DEBUG_sys ) ; then
1116    echo "IGCM_sys_Put_Rest :" $@
1117  fi
1118  if [ $DRYRUN = 0 ]; then
1119    if [ ! -f ${1} ] ; then
1120      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
1121      IGCM_debug_Exit "IGCM_sys_Put_Rest"
1122    fi
1123
1124    typeset RET
1125    #
1126    if [ X${JobType} = XRUN ] ; then
1127      IGCM_sys_Chmod 444 ${1}
1128    fi
1129
1130    #
1131    # USUAL WAY
1132    \cp $1 $2 > out_rsync 2>&1
1133    RET=$?
1134
1135#       #RSYNC WITH NETWORK SSH CALL
1136#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1137#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
1138
1139#       #RSYNC WITH NFS USE
1140#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1141#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1142
1143#       RET=$?
1144#       IGCM_sys_Rsync_out $RET
1145
1146#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1147#       (( RET=RET+$? ))
1148
1149    if [ ${RET} -gt 0 ] ; then
1150      echo "IGCM_sys_Put_Rest : error."
1151      cat out_rsync
1152      IGCM_debug_Exit "IGCM_sys_Put_Rest"
1153    else
1154      \rm out_rsync
1155    fi
1156  else
1157    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1158  fi
1159  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
1160}
1161
1162#D-#==================================================
1163#D-function IGCM_sys_PutBuffer_Rest
1164#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
1165#D-           File and target directory must exist.
1166#D-* Examples:
1167#D-
1168function IGCM_sys_PutBuffer_Rest {
1169  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
1170  if ( $DEBUG_sys ) ; then
1171    echo "IGCM_sys_PutBuffer_Rest :" $@
1172  fi
1173  if [ $DRYRUN = 0 ]; then
1174    if [ ! -f ${1} ] ; then
1175      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
1176      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
1177    fi
1178
1179    typeset RET
1180    #
1181    if [ X${JobType} = XRUN ] ; then
1182      IGCM_sys_Chmod 444 ${1}
1183    fi
1184
1185    #
1186    # USUAL WAY
1187    \cp $1 $2 > out_rsync 2>&1
1188    RET=$?
1189
1190    if [ ${RET} -gt 0 ] ; then
1191      echo "IGCM_sys_PutBuffer_Rest : error."
1192      cat out_rsync
1193      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
1194    else
1195      \rm out_rsync
1196    fi
1197  else
1198    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1199  fi
1200  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
1201}
1202
1203#D-#==================================================
1204#D-function IGCM_sys_Put_Out
1205#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
1206#D-* Examples:
1207#D-
1208function IGCM_sys_Put_Out {
1209  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
1210  if ( $DEBUG_sys ) ; then
1211    echo "IGCM_sys_Put_Out :" $@
1212  fi
1213
1214  typeset NB_ESSAI DELAI RET i
1215
1216  # number of tentative
1217  NB_ESSAI=3
1218  # time delay between tentative
1219  DELAI=2
1220
1221  if [ $DRYRUN = 0 ]; then
1222    if [ ! -f ${1} ] ; then
1223      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
1224      IGCM_debug_PopStack "IGCM_sys_Put_Out"
1225      return 1
1226    fi
1227    #
1228    IGCM_sys_MkdirArchive $( dirname $2 )
1229    #
1230
1231    #=====================================================
1232    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1233    #=====================================================
1234
1235    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
1236    #if [ $? -eq 0 ] ; then
1237    #    typeset WORKPATH FILEPATH
1238    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" )
1239    #    IGCM_sys_MkdirWork ${WORKPATH}
1240    #    FILEPATH=${WORKPATH}/$( basename $2 )
1241    #    #
1242    #    IGCM_sys_Cp ${1} ${FILEPATH}
1243    #fi
1244
1245    if [ X${JobType} = XRUN ] ; then
1246      if [ X${3} = X ] ; then
1247        IGCM_sys_Chmod 444 ${1}
1248      fi
1249    fi
1250    #
1251
1252    (( i = 0 ))
1253    while [ $i -lt $NB_ESSAI ] ; do
1254    # USUAL WAY
1255      \cp $1 $2 > out_rsync 2>&1
1256      RET=$?
1257      if [ ${RET} -gt 0 ]; then
1258        IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed ${i}/${NB_ESSAI}"
1259        IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again."
1260        sleep $DELAI
1261      else
1262        break
1263      fi
1264      (( i = i + 1 ))
1265    done
1266
1267#       #RSYNC WITH NETWORK SSH CALL
1268#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
1269#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
1270
1271#       #RSYNC WITH NFS USE
1272#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
1273#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
1274
1275#       RET=$?
1276#       IGCM_sys_Rsync_out $RET
1277
1278#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1279#       (( RET=RET+$? ))
1280
1281    if [ ${RET} -gt 0 ] ; then
1282      echo "IGCM_sys_Put_Out : error."
1283      cat out_rsync
1284      IGCM_debug_Exit "IGCM_sys_Put_Out"
1285    else
1286      \rm out_rsync
1287    fi
1288  else
1289    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1290  fi
1291  IGCM_debug_PopStack "IGCM_sys_Put_Out"
1292  return 0
1293}
1294
1295#D-#==================================================
1296#D-function IGCM_sys_PutBuffer_Out
1297#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
1298#D-* Examples:
1299#D-
1300function IGCM_sys_PutBuffer_Out {
1301  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
1302  if ( $DEBUG_sys ) ; then
1303    echo "IGCM_sys_PutBuffer_Out :" $@
1304  fi
1305  if [ $DRYRUN = 0 ]; then
1306    if [ ! -f ${1} ] ; then
1307      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
1308      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1309      return 1
1310    fi
1311    #
1312    IGCM_sys_Mkdir $( dirname $2 )
1313    #
1314    typeset RET
1315
1316    if [ X${JobType} = XRUN ] ; then
1317      if [ X${3} = X ] ; then
1318        IGCM_sys_Chmod 444 ${1}
1319      fi
1320    fi
1321    #
1322    # USUAL WAY
1323    \cp $1 $2 > out_rsync 2>&1
1324    RET=$?
1325
1326    if [ ${RET} -gt 0 ] ; then
1327      echo "IGCM_sys_PutBuffer_Out : error."
1328      cat out_rsync
1329      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
1330    else
1331      \rm out_rsync
1332    fi
1333  else
1334    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1335  fi
1336  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
1337  return 0
1338}
1339
1340#D-#==================================================
1341#D-function IGCM_sys_Get
1342#D-* Purpose: Get a file from ${ARCHIVE}
1343#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
1344#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
1345function IGCM_sys_Get {
1346  IGCM_debug_PushStack "IGCM_sys_Get" $@
1347
1348  typeset DEST RET dm_liste ifile target file_work
1349  typeset NB_ESSAI DELAI status i
1350
1351  if ( $DEBUG_sys ) ; then
1352    echo "IGCM_sys_Get :" $@
1353  fi
1354
1355  # number of tentative
1356  NB_ESSAI=3
1357  # time delay between tentative
1358  DELAI=2
1359
1360  if [ $DRYRUN -le 2 ]; then
1361    if [ X${1} = X'/l' ] ; then
1362      # test if the first file is present in the old computation :
1363      eval set +A dm_liste \${${2}}
1364    else
1365      eval set +A dm_liste ${1}
1366    fi
1367    eval DEST=\${${#}}
1368
1369    #=====================================================
1370    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
1371    #=====================================================
1372
1373    # Is it an R_OUT file (not R_IN) ?
1374    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
1375    #if [ $? -eq 0 ] ; then
1376    #    # Yes  ? then we try to get it in SCRATCHDIR
1377    #    set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" )
1378    #    if [ -f ${file_work[0]} ] ; then
1379    #   IGCM_sys_Cp ${file_work[*]} ${DEST}
1380    #   IGCM_debug_PopStack "IGCM_sys_Get"
1381    #   return
1382    #    fi
1383    #fi
1384
1385    ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1386    RET=$?
1387    if [ ${RET} -gt 0 ] ; then
1388      echo "WARNING IGCM_sys_Get : demigration error."
1389      cat out_rsync
1390      echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
1391    fi
1392
1393    #if [ ${RET} -gt 0 ] ; then
1394    #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
1395    #   cat out_rsync
1396    #   echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
1397    #   sleep 30
1398    #   echo "We try another time"
1399    ##  dmget ${dm_liste[*]} > out_rsync 2>&1
1400    #   ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
1401    #   RET=$?
1402    #   if [ ${RET} -gt 0 ] ; then
1403    #       echo "ERROR IGCM_sys_Get : again demigration error :"
1404    #       cat out_rsync
1405    #       IGCM_debug_Exit "IGCM_sys_Get"
1406    #   fi
1407    #    else
1408    #   echo "ERROR IGCM_sys_Get : demigration error :"
1409    #   cat out_rsync
1410    #   IGCM_debug_Exit "IGCM_sys_Get"
1411    #    fi
1412    #fi
1413
1414    #USUAL WAY
1415    if [ X${1} = X'/l' ] ; then
1416      (( RET=0 ))
1417      for target in ${dm_liste[*]} ; do
1418        local_file=$( basename ${target} )
1419        (( i = 0 ))
1420        # test if the target file is present before the loop
1421        IGCM_sys_TestFileArchive ${target}
1422        RET=$?
1423        if [ ${RET} -gt 0 ] ; then
1424          echo "IGCM_sys_Get, ERROR : regular file ${target} DOES NOT EXIST ."
1425          IGCM_debug_Exit "IGCM_sys_Get"
1426        else
1427          while [ $i -lt $NB_ESSAI ] ; do
1428            \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1429            status=$?
1430            if [ ${status} -gt 0 ]; then
1431              IGCM_debug_Print 2 "IGCM_sys_Get : cp failed ${i}/${NB_ESSAI}"
1432              IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
1433              sleep $DELAI
1434            else
1435              break
1436            fi
1437            (( i = i + 1 ))
1438          done
1439          (( RET = RET + status ))
1440        fi
1441      done
1442    else
1443      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
1444      RET=$?
1445    fi
1446
1447#       #RSYNC WITH NETWORK SSH CALL
1448#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
1449#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
1450
1451#       #RSYNC WITH NFS USE
1452#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
1453#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
1454
1455#       RET=$?
1456#       IGCM_sys_Rsync_out $RET
1457
1458#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
1459#       (( RET=RET+$? ))
1460
1461    if [ ${RET} -gt 0 ] ; then
1462      echo "IGCM_sys_Get : copy error."
1463      cat out_rsync
1464      IGCM_debug_Exit "IGCM_sys_Get"
1465    else
1466      \rm out_rsync
1467    fi
1468  else
1469    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1470  fi
1471  IGCM_debug_PopStack "IGCM_sys_Get"
1472}
1473
1474#D-#==================================================
1475#D-function IGCM_sys_GetBuffer
1476#D-* Purpose: Get a file from ${SCRATCHDIR}
1477#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
1478#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
1479function IGCM_sys_GetBuffer {
1480  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
1481
1482  typeset DEST RET buf_liste ifile target file_work
1483
1484  if ( $DEBUG_sys ) ; then
1485    echo "IGCM_sys_GetBuffer :" $@
1486  fi
1487  if [ $DRYRUN -le 2 ]; then
1488    if [ X${1} = X'/l' ] ; then
1489      # test if the first file is present in the old computation :
1490      eval set +A buf_liste \${${2}}
1491    else
1492      eval set +A buf_liste ${1}
1493    fi
1494    eval DEST=\${${#}}
1495
1496    #USUAL WAY
1497    if [ X${1} = X'/l' ] ; then
1498      (( RET=0 ))
1499      for target in ${buf_liste[*]} ; do
1500        local_file=$( basename ${target} )
1501        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
1502        (( RET = RET + $? ))
1503      done
1504    else
1505      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
1506      RET=$?
1507    fi
1508
1509    if [ ${RET} -gt 0 ] ; then
1510      echo "IGCM_sys_GetBuffer : copy error."
1511      cat out_rsync
1512      IGCM_debug_Exit "IGCM_sys_GetBuffer"
1513    else
1514      \rm out_rsync
1515    fi
1516  else
1517    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1518  fi
1519  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
1520}
1521
1522#D-#==================================================
1523#D-function IGCM_sys_GetDate_FichWork
1524#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
1525#D-* Examples:
1526#D-
1527function IGCM_sys_GetDate_FichWork {
1528  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
1529  if ( $DEBUG_sys ) ; then
1530    echo "IGCM_sys_GetDate_FichWork :" $@
1531  fi
1532  typeset dateF
1533  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1534  eval ${2}=${dateF[5]}
1535
1536    # donne la date filesys d'un fichier sur la machine work
1537  IGCM_debug_PopStack "IGCM_sys_FichWork"
1538}
1539
1540#D-#==================================================
1541#D-function IGCM_sys_GetDate_FichArchive
1542#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
1543#D-* Examples:
1544#D-
1545function IGCM_sys_GetDate_FichArchive {
1546  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
1547  if ( $DEBUG_sys ) ; then
1548    echo "IGCM_sys_GetDate_FichArchive :" $@
1549  fi
1550  typeset dateF
1551  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
1552  eval ${2}=${dateF[5]}
1553
1554  IGCM_debug_PopStack "IGCM_sys_FichArchive"
1555}
1556
1557#D-#==================================================
1558#D-function IGCM_sys_Dods_Rm
1559#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
1560#D-* Examples:
1561#D-
1562function IGCM_sys_Dods_Rm {
1563  if ( $DEBUG_sys ) ; then
1564    echo "IGCM_sys_Dods_Rm :" $@
1565  fi
1566  typeset RET
1567  RET=0
1568  if [ $DRYRUN = 0 ]; then
1569
1570#    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
1571#      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
1572#      echo "Nothing has been done."
1573#      return
1574#    fi
1575
1576    /ccc/cont003/home/dsm/p86ipsl/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
1577    RET=$?
1578
1579#       if [ ${RET} -gt 0 ] ; then
1580#           echo "IGCM_sys_Dods_Rm : error."
1581#           cat out_dods_rm
1582#           IGCM_debug_Exit "IGCM_sys_Dods_Rm"
1583#       else
1584#           rm out_dods_rm
1585#       fi
1586
1587  else
1588    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1589  fi
1590  return $RET
1591}
1592
1593#D-#==================================================
1594#D-function IGCM_sys_Dods_Cp
1595#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
1596#D-* Examples:
1597#D-
1598function IGCM_sys_Dods_Cp {
1599  if ( $DEBUG_sys ) ; then
1600    echo "IGCM_sys_Dods_Cp :" $@
1601  fi
1602  typeset RET
1603  RET=0
1604  if [ $DRYRUN = 0 ]; then
1605
1606#    if [ ! -d ${R_SAVE}/${1} ] ; then
1607#      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
1608#      echo "Nothing has been done."
1609#      return
1610#    fi
1611
1612    /ccc/cont003/home/dsm/p86ipsl/bin/dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
1613    RET=$?
1614
1615#       if [ ${RET} -gt 0 ] ; then
1616#           echo "IGCM_sys_Dods_Cp : error."
1617#           cat out_dods_cp
1618#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
1619#       else
1620#           rm out_dods_cp
1621#       fi
1622
1623  else
1624    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1625  fi
1626  return $RET
1627}
1628
1629#D-#==================================================
1630#D-function IGCM_sys_Put_Dods
1631#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
1632#D-* Examples:
1633#D-
1634function IGCM_sys_Put_Dods {
1635  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
1636  if ( $DEBUG_sys ) ; then
1637    echo "IGCM_sys_Put_Dods :" $@
1638  fi
1639  set -vx
1640  typeset RET
1641  if [ $DRYRUN = 0 ]; then
1642    if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then
1643      echo "WARNING IGCM_sys_Put_Dods : None of the following directories exist. Exactly one should."
1644      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} DOES NOT EXIST."
1645      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} DOES NOT EXIST."
1646      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1647      return
1648    fi
1649
1650    if ( [ -d ${R_SAVE}/${1} ] && [ -d ${R_FIGR}/${1} ] ) ; then
1651      echo "WARNING IGCM_sys_Put_Dods : Both of the following directories exist. Exactly one should."
1652      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} EXISTS."
1653      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} EXISTS."
1654      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1655      return
1656    fi
1657    #
1658    if [ -d ${R_SAVE}/${1} ] ; then
1659      cd ${R_SAVE}
1660    elif [ -d ${R_FIGR}/${1} ] ; then
1661      cd ${R_FIGR}
1662    fi
1663
1664    IGCM_sys_Dods_Rm ${1}
1665    IGCM_sys_Dods_Cp ${1}
1666    RET=0
1667
1668    if [ ${RET} -gt 0 ] ; then
1669      echo "IGCM_sys_Put_Dods : error."
1670      IGCM_debug_Exit "IGCM_sys_Put_Dods"
1671    fi
1672  else
1673    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
1674  fi
1675  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
1676}
1677
1678##############################################################
1679# REBUILD OPERATOR
1680
1681function IGCM_sys_rebuild {
1682  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
1683  if ( $DEBUG_sys ) ; then
1684    echo "IGCM_sys_rebuild :" $@
1685  fi
1686  /home/cont003/p86ipsl/X64/bin/rebuild -f -o $@
1687  if [ $? -gt 0 ] ; then
1688    echo "IGCM_sys_rebuild : erreur ${@}."
1689    IGCM_debug_Exit "rebuild"
1690  fi
1691
1692  IGCM_debug_PopStack "IGCM_sys_rebuild"
1693}
1694
1695function IGCM_sys_rebuild_station {
1696  IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@
1697  typeset i list_opt file_in file_out prefix_invert list_invert
1698  if ( $DEBUG_sys ) ; then
1699    echo "IGCM_sys_rebuild_station :" $@
1700  fi
1701  list_opt=$@
1702
1703  # Invert Axis : t,x -> x,t
1704  #               t,pres,x -> x,t,pres
1705  # So that we can concatenate along x
1706  i=0
1707  for file_in in ${list_opt} ; do
1708    (( i = i + 1))
1709    [ ${i} = 1 ] && file_out=${file_in} && continue
1710    prefix_invert=$( basename ${file_in} .nc )
1711    IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc
1712    list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc
1713  done
1714
1715  # Concatenate
1716  IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc
1717
1718  # Re-ivert file
1719  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}
1720
1721  # Station re-ordering is too expansive to be run within libICGM
1722  # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.
1723  # This re-ordering must be done "in memory" by the cmorization process
1724  # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)
1725  # BEGIN reordering
1726
1727  # Only LMDZ text output contains the exact ordering of the station.
1728  # We isolate this in the code below:
1729  #  0  38  -157.5000000000000  70.98591549295774
1730  #  0  54  27.49999999999999   67.18309859154928
1731  #  0  56  -62.50000000000001  82.39436619718309
1732  #  0  79  12.49999999999999   78.59154929577466
1733  #  0  116 -165.0000000000000  76.05633802816901
1734  #  0  117 130.0000000000000   70.98591549295774
1735  #  0  118 110.0000000000000   87.46478873239437
1736  #  1  40  4.999999999999995   51.97183098591550
1737#  typeset iStation iProc list_opt file_in file_out prefix_invert
1738#  typeset -Z4 j4
1739#  typeset -Z3 j3
1740
1741#  unset list_opt
1742#  set +A list_opt $@
1743
1744  # Filename after rebuild
1745#  file_out=${list_opt[0]}
1746  # Prefix of output files
1747#  prefix_invert=$( basename ${file_out} .nc )
1748  # Number of procs
1749#  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )
1750
1751#  iProc=0
1752#  while [ ${iProc} -lt ${num_proc} ] ; do
1753    # Array containing Station as a number
1754#    unset proc_stn
1755#    set +A proc_stn $( grep "iophy_mpi rank ip lon lat  $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | awk ' {print $2}' )
1756    # Number of stations produced by processor proc
1757#    stationLast=${#proc_stn[*]}
1758    # Proc number on 4 digits
1759#    j4=${iProc}
1760    # Init
1761#    iStation=0
1762#    while [ ${iStation} -lt ${stationLast} ] ; do
1763      # Station number on 3 digits
1764#      j3=${proc_stn[${iStation}]}
1765      # Extract station
1766      # Invert Axis : t,x -> x,t
1767      #               t,pres,x -> x,t,pres
1768      # So that we can concatenate along x
1769#      IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc
1770#      (( iStation = iStation + 1 ))
1771#    done
1772#    (( iProc = iProc + 1 ))
1773#  done
1774
1775  # Concatenate all station along x
1776#  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc
1777
1778  # Re-invert file
1779#  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}
1780
1781  # END reordering
1782
1783  IGCM_debug_PopStack "IGCM_sys_rebuild_station"
1784}
1785
1786############################################################
1787# Activate Running Environnment Variables
1788
1789function IGCM_sys_activ_variables {
1790  IGCM_debug_PushStack "IGCM_sys_activ_variables"
1791  if ( $DEBUG_sys ) ; then
1792    echo "IGCM_sys_activ_variables"
1793  fi
1794
1795  ulimit -s unlimited
1796
1797  export KMP_STACKSIZE=3g
1798  export KMP_LIBRARY=turnaround
1799  export MKL_SERIAL=YES
1800  unset MPI_PLACING_MODE
1801
1802  # add module load nb of threads for core placement
1803  (( max_omp = 0 ))
1804
1805  for comp in ${config_ListOfComponents[*]} ; do
1806    eval ExeNameIn=\${config_Executable_${comp}[0]}
1807    eval ExeNameOut=\${config_Executable_${comp}[1]}
1808
1809    # Only if we really have an executable for the component :
1810    if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
1811      eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1812      if [ ${comp_proc_omp_loc} -gt ${max_omp} ] ; then
1813        (( max_omp = comp_proc_omp_loc ))
1814      fi
1815    fi
1816  done
1817
1818  ( [ X${max_omp} = X4 ] || [ X${max_omp} = X8 ] ) &&  { module load openmp/${max_omp}thds ; IGCM_debug_Print 1 "module load openmp/${max_omp}thds" ; }
1819
1820  IGCM_debug_PopStack "IGCM_sys_activ_variables"
1821}
1822
1823############################################################
1824# Desactivate Running Environnment Variables
1825
1826function IGCM_sys_desactiv_variables {
1827  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
1828  if ( $DEBUG_sys ) ; then
1829    echo "IGCM_sys_desactiv_variables"
1830  fi
1831  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
1832}
1833
1834############################################################
1835# Build MPI/OMP scripts run file (dummy function)
1836
1837function IGCM_sys_build_run_file {
1838
1839IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
1840
1841}
1842
1843############################################################
1844# Build MPI/OMP scripts
1845function IGCM_sys_build_execution_scripts
1846{
1847  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
1848  if ( $DEBUG_sys ) ; then
1849    echo "IGCM_sys_build_execution_scripts " $@
1850  fi
1851  typeset nodes listnodes init_node start_num init_exec comp ExeNameIn ExeNameOut
1852  typeset node_num_current node_current comp_proc_mpi_loc comp_proc_omp_loc
1853  typeset num_corempi nombre_restant_node nombre_restant_comp
1854  typeset IGCM_OMP
1855
1856  if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then
1857    IGCM_debug_Exit "IGCM_sys_titane build_execution_scripts : Job_${config_UserChoices_JobName} doesn't exist in SUBMIT_DIR : ${SUBMIT_DIR} "
1858  fi
1859
1860  if ( ${OK_PARA_MPMD} ) ; then
1861
1862    if [ -f run_file ] ; then
1863      IGCM_sys_Rm -f run_file
1864    fi
1865    touch run_file
1866
1867    if ( ${OK_PARA_OMP} ) ; then
1868
1869      #  Hosts treatment
1870
1871      ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp
1872
1873      i=0
1874      rm -f hosts
1875      IGCM_debug_Print 1 "sys Titane, Hosts avaible :"
1876      for nodes in `cat hosts.tmp` ; do
1877        host[$i]=$nodes
1878        echo "${host[$i]} slots=8 max_slots=8" >> hosts
1879        IGCM_debug_Print 1 ${host[$i]}
1880        i=$((i+1))
1881      done
1882      rm -f hosts.tmp
1883
1884      listnodes=${host[*]}
1885
1886      EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts"
1887
1888      # Initialisation
1889
1890      init_node=y
1891      node_num_current=0
1892      start_num=0
1893      init_exec=n
1894
1895      # Test : if oasis is there, we put it at the first position
1896
1897      for comp in ${config_ListOfComponents[*]} ; do
1898
1899        if [ "X${comp}" = "XCPL" ]  ; then
1900
1901          eval ExeNameIn=\${config_Executable_${comp}[0]}
1902          eval ExeNameOut=\${config_Executable_${comp}[1]}
1903
1904          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1905          echo ""  >> script_${ExeNameOut}.ksh
1906          echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1907          echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
1908          echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
1909          echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err"  >> script_${ExeNameOut}.ksh
1910          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1911
1912          init_node=n
1913
1914          (( nombre_restant_node = NUM_COREPERNODE - 1 ))
1915          node_num_current=0
1916          node_current=${host[${node_num_current}]}
1917
1918          EXECUTION="${EXECUTION} -H ${node_current} -np 1 ./script_${ExeNameOut}.ksh"
1919
1920          init_exec=y
1921          start_num=1
1922
1923        fi
1924
1925      done
1926
1927      # Then loop on the components (except for oasis)
1928
1929      for comp in ${config_ListOfComponents[*]} ; do
1930
1931        eval ExeNameIn=\${config_Executable_${comp}[0]}
1932        eval ExeNameOut=\${config_Executable_${comp}[1]}
1933
1934        # Only if we really have an executable for the component :
1935        if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] ) ; then
1936
1937          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
1938          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
1939
1940          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
1941          # echo "set -vx" >> script_${ExeNameOut}.ksh
1942          echo ""  >> script_${ExeNameOut}.ksh
1943          echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
1944          echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
1945          echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
1946          echo "export OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
1947          echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >>  script_${ExeNameOut}.ksh
1948          echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}"  >> script_${ExeNameOut}.ksh
1949          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
1950
1951          node_num=0
1952
1953          # We define the number of MPI process to be assigned for the component
1954
1955          nombre_restant_comp=${comp_proc_mpi_loc}
1956
1957          # Loop on the allocated nodes
1958
1959          for node in ${listnodes} ; do
1960
1961            # We go to the current node
1962            if [ ${node_num} = ${node_num_current} ] ; then
1963
1964              node_current=${host[${node_num_current}]}
1965
1966              # If first time on the node : initialisation
1967
1968              if [ ${init_node} = y ] ; then
1969                nombre_restant_node=${NUM_COREPERNODE}
1970              fi
1971
1972              # Test on the number of OMP threads
1973
1974              if [ ${comp_proc_omp_loc} -gt ${nombre_restant_node} ] ; then
1975                (( node_num = node_num + 1 ))
1976                node_num_current=${node_num}
1977                init_node=y
1978                continue
1979              fi
1980
1981              # Number of MPI process to assign
1982
1983              (( num_corempi = nombre_restant_node / comp_proc_omp_loc ))
1984
1985              if [ ${num_corempi} -gt ${nombre_restant_comp} ] ; then
1986                num_corempi=${nombre_restant_comp}
1987              fi
1988
1989              (( nombre_restant_node = nombre_restant_node - num_corempi * comp_proc_omp_loc ))
1990              (( nombre_restant_comp = nombre_restant_comp - num_corempi ))
1991
1992              if [ ${init_exec} = y ] ; then
1993                EXECUTION="${EXECUTION} : -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh"
1994              else
1995                EXECUTION="${EXECUTION} -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh"
1996                init_exec=y
1997              fi
1998
1999              ((  start_num = num_corempi + start_num ))
2000
2001            else
2002
2003              (( node_num = node_num + 1 ))
2004              continue
2005            fi
2006
2007            # Test on the number of core/process remaining on the node/component
2008
2009            if [ ${nombre_restant_node} = 0 ] ; then
2010              (( node_num = node_num + 1 ))
2011              node_num_current=${node_num}
2012              init_node=y
2013
2014              if [ ${nombre_restant_comp} = 0 ] ; then
2015                break 1
2016              fi
2017            else
2018
2019              node_num_current=${node_num}
2020              init_node=n
2021
2022              if [ ${nombre_restant_comp} = 0 ] ; then
2023                break 1
2024              fi
2025            fi
2026          done
2027        fi
2028      done
2029
2030    else
2031
2032        # Then first loop on the components for the coupler ie oasis
2033
2034        ## the coupler ie oasis must be the first one
2035        for comp in ${config_ListOfComponents[*]} ; do
2036
2037            eval ExeNameOut=\${config_Executable_${comp}[1]}
2038
2039        # for CPL component only
2040            if [ "X${comp}" = "XCPL" ] ; then
2041                eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
2042                echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file
2043            fi
2044        done
2045
2046        # Then second loop on the components
2047
2048        for comp in ${config_ListOfComponents[*]} ; do
2049
2050            eval ExeNameOut=\${config_Executable_${comp}[1]}
2051
2052            # Only if we really have an executable for the component and not the coupler ie oasis:
2053            if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
2054                eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
2055                echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
2056            fi
2057        done
2058        IGCM_sys_Chmod u+x run_file
2059
2060        EXECUTION="${HOST_MPIRUN_COMMAND} --app ./run_file"
2061
2062    fi
2063
2064  else # Only one executable.
2065      # Check has to be added with :
2066      # Job :
2067      # #MSUB -n 8 # reservation des processeurs pour le job
2068      # #MSUB -N 4 # reservation des nodes pour le job
2069      # BATCH_NUM_PROC_TOT=32
2070      #
2071      # config.card :
2072      # ATM= (gcm.e, lmdz.x, 8MPI, 4OMP)
2073      #
2074      # tested with :
2075      # Job :
2076      # #MSUB -n 32
2077      # BATCH_NUM_PROC_TOT=32
2078      #
2079      # config.card :
2080      # ATM= (gcm.e, lmdz.x)
2081
2082
2083      for comp in ${config_ListOfComponents[*]} ; do
2084
2085          # Only if we really have an executable for the component :
2086          eval ExeNameOut=\${config_Executable_${comp}[1]}
2087###       if ( [ "X${ExeNameOut}" != X\"\" ] ) ; then
2088          if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
2089
2090              IGCM_OMP=1
2091
2092              if ( ${OK_PARA_OMP} ) ; then
2093                  eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
2094                  export OMP_NUM_THREADS=${comp_proc_omp_loc}
2095                  IGCMG_OMP=${comp_proc_omp_loc}
2096              fi
2097              if  ( ${OK_PARA_MPI} ) ; then
2098                  eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
2099                  # Default : mpirun used if nb_proc gt 1
2100                  # pour sortie out/err par process ? more test required
2101                  # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}"  >> script_${ExeNameOut}.ksh
2102                  EXECUTION="${HOST_MPIRUN_COMMAND} -np ${comp_proc_mpi_loc} ./${ExeNameOut}"
2103              else
2104                  # Check if BATCH_NUM_PROC_TOT = IGCMG_OMP
2105                  if ( [  ${IGCM_OMP} -ne ${BATCH_NUM_PROC_TOT} ] ) ; then
2106                      IGCM_debug_Print 1 "sys Titane : BATCH_NUM_PROC_TOT <> ${comp}_PROC_OMP : ${BATCH_NUM_PROC_TOT} <> ${BRIDGE_MSUB_NPROC} "
2107                      IGCM_debug_Print 1 "sys Titane : Check #MSUB -n xx into Job"
2108                      IGCM_debug_Exit "IGCM_sys_build_execution_scripts"
2109                  fi
2110                  # Default : mpirun is NOT used if nb_proc eq 1
2111                  # pour sortie out/err par process ? more test required
2112                  # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh
2113                  EXECUTION="/usr/bin/time ./${ExeNameOut}"
2114              fi
2115          fi
2116      done
2117
2118  fi
2119
2120  IGCM_debug_Print 1 "sys Titane : La commande d execution est "
2121  IGCM_debug_Print 1 "$EXECUTION"
2122
2123  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
2124}
2125
2126############################################################
2127# Check of space available on temporary filesytems
2128function IGCM_sys_check_quota {
2129  IGCM_debug_PushStack "IGCM_sys_check_quota"
2130  if ( $DEBUG_sys ) ; then
2131    echo "IGCM_sys_check_quota "
2132  fi
2133  # Limit of quota (in %)
2134  limit_quota=90
2135
2136  # Check of the volume
2137  volume_quota=$(ccc_quota | grep ' scratch' | awk '{print $2}')
2138  volume_avail=$(ccc_quota | grep ' scratch' | awk '{print $3}')
2139
2140  if ( [ ! X${volume_quota} = X ] && [ ! ${volume_quota} = "-" ] ) ; then
2141
2142    unit_avail=${volume_avail: -1}
2143    unit_quota=${volume_quota: -1}
2144
2145    if [ "${unit_quota}" = "*" ] ; then
2146        IGCM_debug_Print 1 "Please, check your quota of volume on scratch"
2147        IGCM_debug_Print 1 "More than 100% of your quota is used"
2148        IGCM_debug_Print 1 "Use the ccc_quota command to check"
2149        IGCM_debug_Print 1 "You must have more than 10% available to run"
2150        IGCM_debug_Exit "Not enough space to run ! STOP HERE"
2151        IGCM_debug_Verif_Exit
2152    fi
2153
2154    temp_avail=${volume_avail%%${volume_avail: -1}*}
2155    temp_quota=${volume_quota%%${volume_quota: -1}*}
2156
2157    if [ ! ${unit_avail} = ${unit_quota} ] ; then
2158
2159    # Convertion
2160      if [ ${volume_avail: -1} = "T" ] ; then
2161        (( temp_avail = temp_avail * 1000000000000 ))
2162      elif [ ${volume_avail: -1} = "G" ] ; then
2163        (( temp_avail = temp_avail * 1000000000 ))
2164      elif [ ${volume_avail: -1} = "M" ] ; then
2165        (( temp_avail = temp_avail * 1000000 ))
2166      elif [ ${volume_avail: -1} = "k" ] ; then
2167        (( temp_avail = temp_avail * 1000 ))
2168      else
2169        (( temp_avail = volume_avail ))
2170      fi
2171      if [ ${volume_quota: -1} = "T" ] ; then
2172        (( temp_quota = temp_quota * 1000000000000 ))
2173      elif [ ${volume_quota: -1} = "G" ] ; then
2174        (( temp_quota = temp_quota * 1000000000 ))
2175      elif [ ${volume_quota: -1} = "M" ] ; then
2176        (( temp_quota = temp_quota * 1000000 ))
2177      elif [ ${volume_quota: -1} = "k" ] ; then
2178        (( temp_quota = temp_quota * 1000 ))
2179      else
2180        (( temp_quota = volume_quota ))
2181      fi
2182    fi
2183
2184    quota_volume=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc)
2185#    echo "volume ratio is " $quota_volume
2186
2187    if [ ${quota_volume} -ge ${limit_quota} ] ; then
2188      IGCM_debug_Print 1 "Please, check your quota of volume on scratch"
2189      IGCM_debug_Print 1 "${quota_volume}% of your quota is used"
2190      IGCM_debug_Print 1 "Use the ccc_quota command to check"
2191      IGCM_debug_Print 1 "You must have more than 10% available to run"
2192      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
2193      IGCM_debug_Verif_Exit
2194    fi
2195
2196  fi
2197
2198# Check of the number of inodes
2199
2200  inode_quota=$(ccc_quota | grep ' scratch' | awk '{print $6}')
2201  inode_avail=$(ccc_quota | grep ' scratch' | awk '{print $7}')
2202
2203  if ( [ ! X${inode_quota} = X ] && [ ! ${inode_quota} = "-" ] ) ; then
2204
2205    unit_avail=${inode_avail: -1}
2206    unit_quota=${inode_quota: -1}
2207
2208    if [ "${unit_quota}" = "*" ] ; then
2209        IGCM_debug_Print 1 "Please, check your quota of inode on scratch"
2210        IGCM_debug_Print 1 "More than 100% of your quota is used"
2211        IGCM_debug_Print 1 "Use the ccc_quota command to check"
2212        IGCM_debug_Print 1 "You must have more than 10% available to run"
2213        IGCM_debug_Exit "Not enough space to run ! STOP HERE"
2214        IGCM_debug_Verif_Exit
2215    fi
2216
2217    temp_avail=${inode_avail%%${inode_avail: -1}*}
2218    temp_quota=${inode_quota%%${inode_quota: -1}*}
2219
2220    if [ ! ${unit_avail} = ${unit_quota} ] ; then
2221
2222    # Convertion
2223      if [ ${inode_avail: -1} = "T" ] ; then
2224        (( temp_avail = temp_avail * 1000000000000 ))
2225      elif [ ${inode_avail: -1} = "G" ] ; then
2226        (( temp_avail = temp_avail * 1000000000 ))
2227      elif [ ${inode_avail: -1} = "M" ] ; then
2228        (( temp_avail = temp_avail * 1000000 ))
2229      elif [ ${inode_avail: -1} = "k" ] ; then
2230        (( temp_avail = temp_avail * 1000 ))
2231      else
2232        (( temp_avail = inode_avail ))
2233      fi
2234
2235      if [ ${inode_quota: -1} = "T" ] ; then
2236        (( temp_quota = temp_quota * 1000000000000 ))
2237      elif [ ${inode_quota: -1} = "G" ] ; then
2238        (( temp_quota = temp_quota * 1000000000 ))
2239      elif [ ${inode_quota: -1} = "M" ] ; then
2240        (( temp_quota = temp_quota * 1000000 ))
2241      elif [ ${inode_quota: -1} = "k" ] ; then
2242        (( temp_quota = temp_quota * 1000 ))
2243      else
2244        (( temp_quota = inode_quota ))
2245      fi
2246    fi
2247    quota_inode=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc)
2248#    echo "inode ratio is " $quota_inode
2249
2250    if [ ${quota_inode} -ge ${limit_quota} ] ; then
2251      IGCM_debug_Print 1 "Please, check your quota of inode on scratch"
2252      IGCM_debug_Print 1 "${quota_inode}% of your quota is used"
2253      IGCM_debug_Print 1 "Use the ccc_quota command to check"
2254      IGCM_debug_Print 1 "You must have more than 10% available to run"
2255      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
2256      IGCM_debug_Verif_Exit
2257    fi
2258
2259  fi
2260  IGCM_debug_PopStack "IGCM_sys_check_quota"
2261}
2262
2263##############################################################
2264# NCO OPERATOR
2265
2266function IGCM_sys_ncap2 {
2267  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
2268  if ( $DEBUG_sys ) ; then
2269    echo "IGCM_sys_ncap2 :" $@
2270  fi
2271  ncap2 "$@"
2272  if [ $? -gt 0 ] ; then
2273    echo "IGCM_sys_ncap2 : erreur ${@}."
2274    IGCM_debug_Exit "ncap2"
2275  fi
2276
2277  IGCM_debug_PopStack "IGCM_sys_ncap2"
2278}
2279
2280function IGCM_sys_ncatted {
2281  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
2282  if ( $DEBUG_sys ) ; then
2283    echo "IGCM_sys_ncatted :" $@
2284  fi
2285  ncatted "$@"
2286  if [ $? -gt 0 ] ; then
2287    echo "IGCM_sys_ncatted : erreur ${@}."
2288    IGCM_debug_Exit "ncatted"
2289  fi
2290
2291  IGCM_debug_PopStack "IGCM_sys_ncatted"
2292}
2293
2294function IGCM_sys_ncbo {
2295  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
2296  if ( $DEBUG_sys ) ; then
2297    echo "IGCM_sys_ncbo :" $@
2298  fi
2299  ncbo $@
2300  if [ $? -gt 0 ] ; then
2301    echo "IGCM_sys_ncbo : erreur ${@}."
2302    IGCM_debug_Exit "ncbo"
2303  fi
2304
2305  IGCM_debug_PopStack "IGCM_sys_ncbo"
2306}
2307
2308function IGCM_sys_ncdiff {
2309  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
2310  if ( $DEBUG_sys ) ; then
2311    echo "IGCM_sys_ncdiff :" $@
2312  fi
2313  ncdiff $@
2314  if [ $? -gt 0 ] ; then
2315    echo "IGCM_sys_ncdiff : erreur ${@}."
2316    IGCM_debug_Exit "ncdiff"
2317  fi
2318
2319  IGCM_debug_PopStack "IGCM_sys_ncdiff"
2320}
2321
2322function IGCM_sys_ncea {
2323  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
2324  if ( $DEBUG_sys ) ; then
2325    echo "IGCM_sys_ncea :" $@
2326  fi
2327  ncea $@
2328  if [ $? -gt 0 ] ; then
2329    echo "IGCM_sys_ncea : erreur ${@}."
2330    IGCM_debug_Exit "ncea"
2331  fi
2332
2333  IGCM_debug_PopStack "IGCM_sys_ncea"
2334}
2335
2336function IGCM_sys_ncecat {
2337  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
2338  if ( $DEBUG_sys ) ; then
2339    echo "IGCM_sys_ncecat :" $@
2340  fi
2341  ncecat $@
2342  if [ $? -gt 0 ] ; then
2343    echo "IGCM_sys_ncecat : erreur ${@}."
2344    IGCM_debug_Exit "ncecat"
2345  fi
2346
2347  IGCM_debug_PopStack "IGCM_sys_ncecat"
2348}
2349
2350function IGCM_sys_ncflint {
2351  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
2352  if ( $DEBUG_sys ) ; then
2353    echo "IGCM_sys_ncflint :" $@
2354  fi
2355  ncflint $@
2356  if [ $? -gt 0 ] ; then
2357    echo "IGCM_sys_ncflint : erreur ${@}."
2358    IGCM_debug_Exit "ncflint"
2359  fi
2360
2361  IGCM_debug_PopStack "IGCM_sys_ncflint"
2362}
2363
2364function IGCM_sys_ncks {
2365  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
2366  if ( $DEBUG_sys ) ; then
2367    echo "IGCM_sys_ncks :" $@
2368  fi
2369  ncks $@
2370  if [ $? -gt 0 ] ; then
2371    echo "IGCM_sys_ncks : erreur ${@}."
2372    IGCM_debug_Exit "ncks"
2373  fi
2374
2375  IGCM_debug_PopStack "IGCM_sys_ncks"
2376}
2377
2378function IGCM_sys_ncpdq {
2379  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
2380  if ( $DEBUG_sys ) ; then
2381    echo "IGCM_sys_ncpdq :" $@
2382  fi
2383  ncpdq $@
2384  if [ $? -gt 0 ] ; then
2385    echo "IGCM_sys_ncpdq : erreur ${@}."
2386    IGCM_debug_Exit "ncpdq"
2387  fi
2388
2389  IGCM_debug_PopStack "IGCM_sys_ncpdq"
2390}
2391
2392function IGCM_sys_ncra {
2393  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
2394  if ( $DEBUG_sys ) ; then
2395    echo "IGCM_sys_ncra :" $@
2396  fi
2397  ncra $@
2398  if [ $? -gt 0 ] ; then
2399    echo "IGCM_sys_ncra : erreur ${@}."
2400    IGCM_debug_Exit "ncra"
2401  fi
2402
2403  IGCM_debug_PopStack "IGCM_sys_ncra"
2404}
2405
2406function IGCM_sys_ncrcat {
2407  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
2408  if ( $DEBUG_sys ) ; then
2409    echo "IGCM_sys_ncrcat :" $@
2410  fi
2411  ncrcat --omp_num_threads 2 $@
2412  if [ $? -gt 0 ] ; then
2413    echo "IGCM_sys_ncrcat : erreur ${@}."
2414#       IGCM_debug_Exit "ncrcat"
2415  fi
2416
2417  IGCM_debug_PopStack "IGCM_sys_ncrcat"
2418}
2419
2420function IGCM_sys_ncrename {
2421  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
2422  if ( $DEBUG_sys ) ; then
2423    echo "IGCM_sys_ncrename :" $@
2424  fi
2425  ncrename $@
2426  if [ $? -gt 0 ] ; then
2427    echo "IGCM_sys_ncrename : erreur ${@}."
2428    IGCM_debug_Exit "ncrename"
2429  fi
2430
2431  IGCM_debug_PopStack "IGCM_sys_ncrename"
2432}
2433
2434function IGCM_sys_ncwa {
2435  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
2436  if ( $DEBUG_sys ) ; then
2437    echo "IGCM_sys_ncwa :" $@
2438  fi
2439  ncwa $@
2440  if [ $? -gt 0 ] ; then
2441    echo "IGCM_sys_ncwa : erreur ${@}."
2442    IGCM_debug_Exit "ncwa"
2443  fi
2444
2445  IGCM_debug_PopStack "IGCM_sys_ncwa"
2446}
2447
2448##############################################################
2449# CDO OPERATOR
2450
2451function IGCM_sys_cdo {
2452  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
2453  if ( $DEBUG_sys ) ; then
2454    echo "IGCM_sys_cdo :" $@
2455  fi
2456  \cdo $@
2457  if [ $? -gt 0 ] ; then
2458    echo "IGCM_sys_cdo : erreur ${@}."
2459    IGCM_debug_PopStack "IGCM_sys_cdo"
2460    return 1
2461  else
2462    IGCM_debug_PopStack "IGCM_sys_cdo"
2463    return 0
2464  fi
2465
2466  IGCM_debug_PopStack "IGCM_sys_cdo"
2467}
Note: See TracBrowser for help on using the repository browser.