[MITgcm-support] problem reading binary grid file ...

Dimitris Menemenlis menemenlis at jpl.nasa.gov
Fri Apr 22 08:13:08 EDT 2016


maybe you get zeros because you are specifying bathymetry with positive 
instead of negative numbers?

On 04/22/2016 04:00 AM, Ufuk Turuncoglu wrote:
> Hi,
>
> I am trying to create a grid file in binary format using python. In this
> case, the script is very simple and it writes numpy array using
> following command in big-endian format,
>
> var.astype('>f4').tofile('BATHY_BS.data')
>
> Then i am running MITgcm and it produces intermediate files such as
> Depth.data etc. Then, if i check the Depth.data using following NCL script,
>
> begin
>    ;--- parameters ---
>    endian = "BigEndian"
>    nlat = 280 ;264 ;280
>    nlon = 466 ;;570 ;466
>
>    ;--- set file option ---
>    setfileoption("bin", "ReadByteOrder", endian)
>
>    ;--- read bathymetry ---
>    h = fbindirread("Depth.data", 0, (/ nlat, nlon /), "float")
>
>    ;--- plot data ---
>    wks  = gsn_open_wks ("newpdf", "check")
>    gsn_define_colormap (wks, "matlab_jet")
>    i = NhlNewColor(wks,0.8,0.8,0.8)
>
>    ;--- define plot resource ---
>    res = True
>    res at gsnAddCyclic = False
>    res at gsnFrame = False
>    res at gsnLeftString = ""
>    res at gsnRightString = ""
>    res at gsnSpreadColors = True
>    res at gsnSpreadColorEnd = -3
>    res at cnFillOn = True
>    res at cnFillMode = "RasterFill"
>    res at cnInfoLabelOn = False
>    res at cnLinesOn = False
>    res at cnLineLabelsOn = False
>    res at lbLabelBarOn = False
>    res at pmTickMarkDisplayMode = "Always"
>    res at tiXAxisFontHeightF = 0.008
>    res at tiYAxisFontHeightF = 0.008
>    res at tmXBLabelFontHeightF = 0.008
>    res at tmYLLabelFontHeightF = 0.008
>
>    plot = gsn_csm_contour(wks, h, res)
>    draw(plot)
>    frame(wks)
> end
>
> The output seems wrong and i could not see the correct data and plot
> have full of zeros. First i thought that it is an issue related with the
> Python and binary data file but the same NCL script could read other
> data files (i.e. DXC.data - the delx, dely and delz are provided in data
> file) generated by MITgcm and BATHY_BS.data file produced by Python
> script without any problem. As i know that the binary files must be
> written using single record direct access and the Python script must
> work at this point. I think that MITgcm could not read Python generated
> file correctly but i don't know why. Anyway, do you have similar
> experience? Any suggestion could be helpful. I also try to generate grid
> data using Fortran but the result is same. You can find the content of
> my config file to install MITgcm.
>
> Regards,
>
> --ufuk
>
> #!/bin/bash
> #
> # $Header: /u/gcmpack/MITgcm/tools/build_options/linux_amd64_ifort11,v
> 1.6 2011/07/07 22:58:36 jmc Exp $
> # $Name: checkpoint63a $
> #
> #  Constantinos Evangelinos
> #
> #  Build options for the intel 11 & 12 fortran compiler
> #
> #  Tested on baudelaire (FC 13) with intel compiler v.11.1.073 (20100806)
>
> # OpenMP : tested on danton (FC 14) using intel compiler v.11.1.046
> (20090630)
> #                                              and also v.12.0.4 (20110427)
>
> #-------
> # run with OpenMP: needs to set environment var. OMP_NUM_THREADS
> #    and generally, needs to increase the stack-size:
> #   -  sh,bash:
> #     > export OMP_NUM_THREADS=2
> #     > export KMP_STACKSIZE=400m
> #   - csh,tcsh:
> #     > setenv OMP_NUM_THREADS 2
> #     > setenv KMP_STACKSIZE 400m
> #-------
>
> FC=mpif90
> F90C=mpif90
> CC=icc
> LINK=mpif90
>
> DEFINES='-DWORDLENGTH=4'
> CPP='cpp  -traditional -P'
> F90FIXEDFORMAT='-fixed -Tf'
> EXTENDED_SRC_FLAG='-132'
> GET_FC_VERSION="--version"
> OMPFLAG='-openmp'
>
> NOOPTFLAGS='-O3 -g -fp-model strict'
> NOOPTFILES=''
>
> INCLUDEDIRS=''
> INCLUDES=''
> LIBS=''
>
> if test "x$GENERIC" != x ; then
>      PROCF=-axSSE4.2,SSE4.1,SSSE3,SSE3,SSE2
> else
>      PROCF=-xHost
> fi
>
> #FFLAGS="$FFLAGS -m64 -fPIC -convert big_endian -assume byterecl
> -mcmodel=large"
> FFLAGS="$FFLAGS -m64 -convert big_endian -assume byterecl -mcmodel large
> -shared-intel"
> #FFLAGS="$FFLAGS -m64 -assume byterecl -mcmodel large -shared-intel"
>
> #- might want to use '-r8' for fizhi pkg:
> #FFLAGS="$FFLAGS -r8"
>
> if test "x$IEEE" = x ; then     #- with optimisation:
>      FOPTIM="-O3 -fp-model strict -align -ip -opt-streaming-stores auto
> $PROCF -extend_source"
> else
>    if test "x$DEVEL" = x ; then  #- no optimisation + IEEE :
>      FOPTIM="-O3 -fp-model strict -fp-model source -noalign $PROCF
> -extend_source"
>    else                          #- development/check options:
>     #FFLAGS="$FFLAGS -debug all -debug-parameters all -fp-model strict"
>      FFLAGS="$FFLAGS -warn all -warn nounused"
>      FOPTIM="-fpe0 -ftz -fp-stack-check -check all -ftrapuv"
>      FOPTIM="$FOPTIM -O3 -fp-model strict  -noalign -g -traceback $PROCF"
>    fi
> fi
>
> F90FLAGS=$FFLAGS
> F90OPTIM=$FOPTIM
> CFLAGS="-O3 -fp-model strict -ip -m64 -mcmodel large -shared-intel $PROCF"
>
> #LIBS='-lmpi -L /opt/netcdf/4.1.2/intel/2011/lib -lnetcdf'
> LIBS='-lmpi -L /RS/progs/netcdf/4.3.1.1/intel/lib -lnetcdf'
> #LIBS='-lmpi -L/afs/enea.it/fra/user/sannino2/netcdf-4.1.3/GM/lib -lnetcdf'
> #INCLUDES='-I/opt//openmpi/1.5.3/intel/2011/include/
> -I/opt/netcdf/4.1.2/intel/2011/include/'
> INCLUDES='-I/RS/progs/openmpi/1.10.1/intel/include/
> -I/RS/progs/netcdf/4.3.1.1/intel/include/'
>
>
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mitgcm.org/mailman/listinfo/mitgcm-support



More information about the MITgcm-support mailing list