#ls2(research/Memo/ECPC)

* First step memo for GSM simulation [#j72c29d9]
- For simulations on COMPAS, please see [[here>IT Memo/Compas memo]]
- For simulations on COMPAS, please see [[here>IT memo/Compas Memo]]

#contents
** Customized Installation [#k8ebfbfa]
In gsm
+ Modify source codes (in gsm/src/)
+ Modify gsm/opt/options-[machine]-[arch] for your environment.
+ execute "configure-model"
+ execute "make"
** Current problems [#eb0a8259]
See [[common Q&A>../#a379bec1]].
** Download, Installation, ant Test Run [#w1b27ec0]
 $ setenv CVSROOT :pserver:anoncvs@rokka.ucsd.edu:/rokka1/kana/cvs-server-root/cpscvs
 $ mkdir GSM ; cd GSM (for example)
 $ cvs co Install
 $ ./inst gsm_latest lo   (-> it takes few minutes. Select "single" for arch)
  "gsm_latest" is changeable. For test run, following works.
  $ ./install --model=gsm --date=20061218 lo
 $ limit stacksize unlimited
 $ cd gruns
 $ ./gsm (-> it will make g_000 directory and output)
 
 It takes 12 minutes for 72 hours run by fuyu (one Xeon 3.2G). 
 Check g_000 directory and output files.
** Visualization [#e4bdbad0]
 $ cd g_000 (from $GSMDIR/gruns)
 $ ../../libs/etc/grmap -g0 pgb.ft00
  --> pgb.ft00.idx and pgb.ft00.ctl are made.
 $ grads

Other way (more useful!)
 $ cd g_000
 $ ../../libs/etc/grmap -g0 pgb.ft00
  -> Make template ctl file.
 $ mv pgb.ft00.ctl pgb.ft.ctl
 $ vi pgb.ft.ctl
  Edit option lines as below
   dset /home/kyoshimura/GSMmpi/gruns/g_004/pgb.ft%f2 
   options template yrev
   index /home/kyoshimura/GSMmpi/gruns/g_004/pgb.ft.idx
   tdef    7 linear              00Z9MAR1990     24hr
 $ gribmap -i pgb.ft.ctl
  -> pgb.ft.idx created.
 $ grads
** MPI run [#tebbf300]

 Verified by fuyu. Takes 5 minutes for 72 hours run by 4-cpu.
+ Installation of mpich (See [[here>IT memo/linuxmemo#z1ef84b7]])
 For making it easier, should be installed in "/usr/local/mpich" (-> but you can configure it).
+ Technical tips of gsm-installation. 
++ Similar setup as [[test run>#w1b27ec0]], but select "mpi" for arch.
++ If the installation stops, try below
 1. Change MPICH_DIR in gsm/configure-model 
    (<- when mpich is not installed in /usr/local/mpich)
 2. Delete "-lgm" in EXTRA_LIBS in gsm/opt/options-linux-mpi
++ Make in gsm directory.
 $ cd gsm
 $ make

** Reading GSM script [#wab0d589]
 #!/bin/sh 
 #
 set -ax
 #
 # this script makes 72 hour integration starting from an example initial
 # condition. ideal for first testing the system on new computer system
 #
 # ---------------  user changeable parameters ------------------------
 #
 # Change the following variable if you are running separate experiments
 # from the same directory
 #
 RUNNAME=g_004

Set your runname. Its directory will be created in gruns/.

 #
 # Intervals of sfc execution, sigma output, sfc output and flx output
 # Various options for running the model
 #
 ENDHOUR=144

End time of calculation. 

 INCHOUR=$ENDHOUR
 INTSFCX=48

Don't know

 INTSIG=24
 INTSFC=24

writing out sig.ftXX and sfc.ftXX files in this interval. "0" is equal to "1". If comment out, equal to INTPOST.

 INTPOST=24

making pgb.ftXX and flx.ftXX files in this interval.

 INTRESTART=12
 #
 FCST_RESTART=yes

Rewriting "sigit" and "sfci" in this interval

 #
 #  ------------- below for expert user only --------------------
 #
 # If you wish, you may modify EXECDIR to /tmp directory and keep these
 # scripts on your permanent disk.
 #
 EXECDIR=/home/kyoshimura/GSMmpi/gruns/$RUNNAME
 #
 # -------  do not change below  -------------------------------------
 #
 mkdir -p $EXECDIR 2>/dev/null

Creating working directory 

 #
 INITIAL_SIGMA=/home/kyoshimura/GSMmpi/libs/con/sigft0090030900.asc

Initial sigma-level data. Can be other than ascii format, but format type should be specified in suffix. &color(red){contains what?};

 INITIAL_SFC=/home/kyoshimura/GSMmpi/libs/con/sfcanl90030900.asc
 INITIAL_SFC_FILE_TYPE=osu1

Same as sigma-level data, but for surface. 

 #
 #  blank means use guess (in the sfc file).
 #
 SST_ANL_T0=
 ICE_ANL_T0=
 SNO_ANL_T0=
 SCV_ANL_T0=
 SST_ANL=/home/kyoshimura/GSMmpi/libs/con/sstanl.900309.grib
 ICE_ANL=/home/kyoshimura/GSMmpi/libs/con/clim.ice.grib
 SNO_ANL=
 SCV_ANL=
 #
 INPUT_RESOLUTION=t62k28
 #
 FCST_NPES=4
 #
 # set environmental variables
 #
 . /home/kyoshimura/GSMmpi/gruns/runscr/envset
 #
 #  cd to run directory
 #
 scrnam=`echo $0 | sed 's?.*/??g'`
 cp $0 $EXECDIR/0LOG.$scrnam
 cp ./cvar.env $EXECDIR/0LOG.cvar
 ls -l /home/kyoshimura/GSMmpi/gsm/bin >$EXECDIR/0LOG.bindates
 cd $EXECDIR || exit 8
 #
 #  renew log file
 #
 cat $0 > ERROR.out
 echo '==============' >>ERROR.out
 #
 # Automatic restart
 #
 if [ -s sigit -a -s sigitdt -a -s sfci -a "$FCST_RESTART" = yes ];then
 	#
 	#  Restart
 	#
 	h=`/home/kyoshimura/GSMmpi/libs/etc/fhour sigit`
 	echo fhour in the sigit file = $h

Read the timestamp of "sigit" (restart file). It will be carried to "forecast hour loop".

 else
 	#
 	#  Initial start.
 	#
 	h=00
 	#
 	# Conversion from ascii to native format
 	#
 	fmt=`echo $INITIAL_SIGMA | sed 's/.*\.//g'`
 	/home/kyoshimura/GSMmpi/libs/etc/scnvrt gsm $INITIAL_SFC_FILE_TYPE \
 		62:192:94:28 \
 		-1:-1:-1:-1:-1 \
 		$fmt:bin $INITIAL_SIGMA:$INITIAL_SFC \
 		cnvrt_initial_sig:cnvrt_initial_sfc || exit 8

Convert from ascii format to binary format.

 	#
 	# Find initial date and hour
 	#
 	/home/kyoshimura/GSMmpi/libs/etc/date cnvrt_initial_sig >date.$$ || exit 8
 	read HH MM DD yyyy FH <date.$$ ; rm date.$$
 	echo $yyyy $MM $DD $HH $FH
 	#
 	# Change input resolution to model resolution
 	#
 	/home/kyoshimura/GSMmpi/gruns/runscr/chgr \
 			cnvrt_initial_sig cnvrt_initial_sfc \
 			sigit sfci \
 			$INITIAL_SFC_FILE_TYPE || exit 8

Change resolution of binary files.

 	#
 	#  convert initial sfc file type to model sfc file type
 	#
 	SST_GRB_T0=`eval echo $SST_ANL_T0`
 	SNO_GRB_T0=`eval echo $SNO_ANL_T0`
 	SCV_GRB_T0=`eval echo $SCV_ANL_T0`
 	ICE_GRB_T0=`eval echo $ICE_ANL_T0`
 	export SST_GRB_T0 SNO_GRB_T0 SCV_GRB_T0 ICE_GRB_T0
 	/home/kyoshimura/GSMmpi/gruns/runscr/sfc0 gsm sfci sfco $INITIAL_SFC_FILE_TYPE || exit 8
 	#
 	cp sfco sfci || exit 8
 	cp sigit sigitdt || exit 8
 	cp sigit sig.ft$h || exit 8
 	cp sfci  sfc.ft$h || exit 8
 	#
 	/home/kyoshimura/GSMmpi/libs/etc/date sigit >date.$$ || exit 8
 	read HH MM DD yyyy FH <date.$$ ; rm date.$$
 	echo $yyyy $MM $DD $HH $FH
 	#
 	#  pgb of the initial
 	#
 	if [ no = yes ] ; then
 		/home/kyoshimura/GSMmpi/gruns/runscr/pgb $h $h $INTSFCX || exit 8
 	elif [ no = yes ] ; then
 		/home/kyoshimura/GSMmpi/libs/etc/catpgb
 	fi

pgb (convert from sigma-level to pressure-level) sig.ft00.

 fi
 #
 #  forecast hour loop
 #
 xc=0
 while [ $h -lt $ENDHOUR ] ; do
 	#
 	hx=`expr $h + $INCHOUR`
 	if [ $hx -gt $ENDHOUR ] ; then
 		hx=$ENDHOUR
 	fi
 	if [ $hx -lt 10 ];then hx=0$hx;fi
 	#
 	SST_GRB=`eval echo $SST_ANL`
 	SNO_GRB=`eval echo $SNO_ANL`
 	SCV_GRB=`eval echo $SNO_ANL`
 	ICE_GRB=`eval echo $ICE_ANL`
 	export SST_GRB SNO_GRB SCV_GRB ICE_GRB
 	/home/kyoshimura/GSMmpi/gruns/runscr/fcstparm $INCHOUR $ENDHOUR $INTSFCX \
 			$INTSIG:$INTSFC:$INTPOST:$INTRESTART || exit 8
 	#
 	#  Execute forecast
 	#
 	/home/kyoshimura/GSMmpi/gruns/runscr/fcst $FCSTENV || exit 8
 	#
 	#  pgb of the forecast
 	#
 	if [ @DOPGB@ = yes ] ; then
 		/home/kyoshimura/GSMmpi/gruns/runscr/pgb $h $hx $INTSIG || exit 8
 	elif [ no = yes ] ; then
 		/home/kyoshimura/GSMmpi/libs/etc/catpgb
 	fi
 	#
 	#  find archive files
 	#
 	cp sig.ft$hx sigit || exit 8
 	mv sigp.ft$hx sigitdt  || exit 8
 	cp sfc.ft$hx sfci || exit 8
   #
   h=$hx
 done
 if [ linux = mac -a mpi = mpi ] ; then
         lamclean
         lamhalt
 fi