├── bin └── .gitignore ├── src ├── .gitignore ├── modgsw.F90 ├── cdftools-end.pod ├── cdftools-begin.pod ├── namdom_template_75 ├── cdfmsk.f90 ├── cdfprobe.f90 ├── cdfstatcoord.f90 ├── cdfnamelist.f90 ├── cdfzonalout.f90 ├── cdf_domain_modif.f90 ├── cdfinfo.f90 ├── cdfcoast.f90 ├── cdfcmp.f90 ├── cdfscale.f90 ├── cdffracinv.f90 ├── cdf_domain2bathy.f90 ├── cdfdifmask.f90 ├── cdfpendep.f90 ├── cdffixanom.f90 ├── cdfrmsssh.f90 ├── cdfstdevw.f90 ├── cdfsigntr.f90 ├── cdfcsp.f90 ├── cdfsigi.f90 └── cdficetrp.f90 ├── .gitignore ├── DOC ├── cdftools.css ├── template.tex ├── chkuserdone.ksh ├── Makefile ├── chkguide.ksh └── cdfovide_guide.tex ├── DEV_TOOLS ├── tagfunction.tpl ├── putcdftool4.ksh ├── tagroutine.tpl ├── tagteos10.tpl ├── tagCreateOutput.tpl ├── putclass.ksh ├── cdf_classes.txt ├── tagnc4.tpl ├── tagmodule.tpl ├── tagprogram.tpl └── tagusage.tpl ├── Macrolib ├── macro.gorgon ├── macro.pgi ├── macro.gfortran_hlrn_nc4 ├── macro.mirage ├── macro.gfortran_hlrn ├── macro.ifort_ursus ├── macro.nymphea ├── macro.esmtools ├── macro.ftn_hlrn_nc4 ├── macro.rhodes ├── macro.conda ├── macro.p630 ├── macro.ifort_locean ├── macro.icm ├── macro.sx8 ├── macro.porzig ├── macro.vayu ├── macro.adastra_intel ├── macro.vargas ├── macro.zahir ├── macro.hplaptop ├── macro.ifort_dell ├── macro.gfortran ├── macro.adastra_cray ├── macro.lgge ├── macro.mac ├── macro.ifort_nesh_fe ├── macro.gforhp ├── macro.meto ├── macro.g95 ├── macro.ifort_hlrn4_nc4 ├── macro.occigen2 ├── macro.ifort ├── macro.meolkara ├── macro.bsc ├── macro.cal1 ├── macro.jean-zay ├── macro.occigen ├── macro.ada ├── make.macro_nesh20210212 ├── macro.meolkerg ├── macro.dahu ├── macro.curie ├── macro.irene ├── macro.jade └── macro.ifort_hlrn_nc4 └── License └── CDFTOOLSCeCILL.txt /bin/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.* 3 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | zclass_list.txt 3 | ATTICS/ 4 | -------------------------------------------------------------------------------- /src/modgsw.F90: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meom-group/CDFTOOLS/HEAD/src/modgsw.F90 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | make.macro 3 | *.mod 4 | *.o 5 | *.so 6 | *.pyf 7 | *.pdf 8 | *.log 9 | *.aux 10 | *.idx 11 | *.toc 12 | cdftools.1 13 | *.opod 14 | *.tmp 15 | WIP 16 | -------------------------------------------------------------------------------- /DOC/cdftools.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | color: red; 3 | text-align: left; 4 | } 5 | 6 | h2 { 7 | color: blue; 8 | } 9 | 10 | ul { 11 | list-style-type: disc; 12 | color: red; 13 | } 14 | 15 | ul ul li { 16 | list-style-type: circle; 17 | color: blue; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /DEV_TOOLS/tagfunction.tpl: -------------------------------------------------------------------------------- 1 | !!--------------------------------------------------------------------- 2 | !! *** FUNCTION *** 3 | !! 4 | !! ** Purpose : 5 | !! 6 | !! ** Method : 7 | !! 8 | !!---------------------------------------------------------------------- 9 | 10 | -------------------------------------------------------------------------------- /DEV_TOOLS/putcdftool4.ksh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | 4 | mkdir -p MODIFIED 5 | 6 | for file in *.?90 ; do 7 | cat $file | sed -e '/History/ a\ 8 | \ \ !! : 4.0 : 03/2017 : J.M. Molines ' -e '/CDFTOOLS_3.0/ c\ 9 | \ \ !! CDFTOOLS_4.0 , MEOM 2017 ' -e '/Copyright/ c\ 10 | \ \ !! Copyright (c) 2017, J.-M. Molines ' > MODIFIED/$file 11 | 12 | done 13 | -------------------------------------------------------------------------------- /DEV_TOOLS/tagroutine.tpl: -------------------------------------------------------------------------------- 1 | !!--------------------------------------------------------------------- 2 | !! *** ROUTINE *** 3 | !! 4 | !! ** Purpose : 5 | !! 6 | !! ** Method : 7 | !! 8 | !! References : 9 | !!---------------------------------------------------------------------- 10 | 11 | -------------------------------------------------------------------------------- /DOC/template.tex: -------------------------------------------------------------------------------- 1 | \newpage 2 | \subsection*{\underline{XXX:}} 3 | \addcontentsline{toc}{subsection}{XXX} 4 | \index{XXX} 5 | \begin{description} 6 | \item[Purpose:] 7 | \item[Usage:] {\em } 8 | \item[Input:] 9 | \item[Required mesh\_mask files or other files:] 10 | \item[Output:] 11 | \item[Remark/bugs :] 12 | \item[Associated scripts:] 13 | \end{description} 14 | -------------------------------------------------------------------------------- /DEV_TOOLS/tagteos10.tpl: -------------------------------------------------------------------------------- 1 | LOGICAL :: ll_teos10 = .FALSE. ! teos10 flag 2 | PRINT *,' [-teos10] : use TEOS10 equation of state instead of default EOS80' 3 | PRINT *,' Temperature should be conservative temperature (CT) in deg C.' 4 | PRINT *,' Salinity should be absolute salinity (SA) in g/kg.' 5 | CASE ( '-teos10' ) ; ll_teos10 = .TRUE. 6 | CALL eos_init ( ll_teos10 ) 7 | 8 | -------------------------------------------------------------------------------- /DEV_TOOLS/tagCreateOutput.tpl: -------------------------------------------------------------------------------- 1 | CONTAINS 2 | 3 | SUBROUTINE CreateOutput 4 | !!--------------------------------------------------------------------- 5 | !! *** ROUTINE CreateOutput *** 6 | !! 7 | !! ** Purpose : Create netcdf output file(s) 8 | !! 9 | !! ** Method : Use stypvar global description of variables 10 | !! 11 | !!---------------------------------------------------------------------- 12 | 13 | END SUBROUTINE CreateOutput 14 | 15 | -------------------------------------------------------------------------------- /Macrolib/macro.gorgon: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS (Linux with pgi) 2 | # 3 | NCDF = -I/usr/local/Cluster-Apps/netcdf/pgi/3.6.1/include -L/usr/local/Cluster-Apps/netcdf/pgi/3.6.1/lib -lnetcdf 4 | INCDIR = -I/usr/local/Cluster-Apps/netcdf/pgi/3.6.1/include 5 | 6 | F90=pgf90 7 | #OMP=-mp 8 | OMP= 9 | #NC4 = -D key_netcdf4 10 | NC4 = 11 | 12 | #CMIP6 = -D key_CMIP6 13 | CMIP6 = 14 | 15 | GSW= 16 | #GSW=-D key_GSW 17 | GSWLIB= 18 | #GSWLIB=-lgsw 19 | FFLAGS = -fast $(NCDF) $(NC4) $(CMIP6) $(GSW) -byteswapio $(OMP) 20 | -------------------------------------------------------------------------------- /Macrolib/macro.pgi: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS (Linux with pgi) 2 | # !! $Rev$ 3 | # !! $Date$ 4 | # !! $Id$ 5 | # !!-------------------------------------------------------------- 6 | # 7 | NCDF = -lnetcdf 8 | 9 | F90=pgf90 10 | MPF90=pgf90 11 | OMP= 12 | #OMP=-mp 13 | 14 | #NC4 = -D key_netcdf4 15 | NC4 = 16 | 17 | #CMIP6 = -D key_CMIP6 18 | CMIP6 = 19 | 20 | GSW= 21 | #GSW=-D key_GSW 22 | GSWLIB= 23 | #GSWLIB=-lgsw 24 | 25 | FFLAGS = -fast $(NCDF) $(NC4) $(CMIP6) $(GSW)-byteswapio $(OMP) 26 | 27 | INSTALL=/usr/local/bin 28 | -------------------------------------------------------------------------------- /Macrolib/macro.gfortran_hlrn_nc4: -------------------------------------------------------------------------------- 1 | # module load gcc/4.9.1.hlrn netcdf/4.3.3.1 hdf5/1.8.14 2 | 3 | INCS = $(NETCDF_INC) $(HDF5_INC) 4 | LIBS = $(NETCDF_F90_LIB) $(HDF5_F90_LIB) 5 | 6 | NC4 = -D key_netcdf4 7 | #CMIP6 = -D key_CMIP6 8 | CMIP6 = 9 | 10 | GSW= 11 | #GSW=-D key_GSW 12 | GSWLIB= 13 | #GSWLIB=-lgsw 14 | 15 | F90=gfortran 16 | #OMP=-fopenmp 17 | OMP= 18 | FFLAGS= $(NC4) $(CMIP6) $(GSW) -O $(INCS) $(LIBS) -fno-second-underscore -ffree-line-length-256 $(OMP) 19 | 20 | INSTALL=$(HOME)/local/bin 21 | INSTALL_MAN=$(HOME)/local/man 22 | -------------------------------------------------------------------------------- /DEV_TOOLS/putclass.ksh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | 4 | mkdir -p MODIFIED 5 | 6 | for key in $( cat noclass_lst.txt | awk '{print $1","$NF}' ) ; do 7 | echo $key 8 | file=${key%,*} 9 | class=${key#*,} 10 | echo $file '--->' $class 11 | 12 | cat $file | sed -e '/History/ a\ 13 | \ \ !! : 4.0 : 03/2017 : J.M. Molines ' -e "/!! Software governed/ a\ 14 | \ \ !! @class $class" -e '/CDFTOOLS_3.0/ c\ 15 | \ \ !! CDFTOOLS_4.0 , MEOM 2017 ' -e '/Copyright/ c\ 16 | \ \ !! Copyright (c) 2017, J.-M. Molines ' > MODIFIED/$file 17 | 18 | done 19 | -------------------------------------------------------------------------------- /Macrolib/macro.mirage: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev$ 3 | # $Date$ 4 | # -------------------------------------------------------------- 5 | # 6 | NCDF = -I/usr/local/include -L/usr/local/lib -lnetcdf 7 | 8 | F90=ifort 9 | MPF90=ifort 10 | OMP= 11 | #OMP=-openmp 12 | #NC4 = -D key_netcdf4 13 | NC4 = 14 | 15 | #CMIP6 = -D key_CMIP6 16 | CMIP6 = 17 | 18 | GSW= 19 | #GSW=-D key_GSW 20 | GSWLIB= 21 | #GSWLIB=-lgsw 22 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(OMP) 23 | LMPI=-lmpi 24 | INSTALL=$(HOME)/bin 25 | -------------------------------------------------------------------------------- /Macrolib/macro.gfortran_hlrn: -------------------------------------------------------------------------------- 1 | # module load gcc/4.9.1.hlrn netcdf/4.3.3.1 hdf5/1.8.14 2 | 3 | INCS = $(NETCDF_INC) $(HDF5_INC) 4 | LIBS = $(NETCDF_F90_LIB) $(HDF5_F90_LIB) 5 | 6 | F90=gfortran 7 | OMP= 8 | #OMP=-fopenmp 9 | 10 | #NC4 = -D key_netcdf4 11 | NC4 = 12 | 13 | #CMIP6 = -D key_CMIP6 14 | CMIP6= 15 | 16 | GSW= 17 | #GSW=-D key_GSW 18 | GSWLIB= 19 | #GSWLIB=-lgsw 20 | 21 | FFLAGS= -O $(INCS) $(LIBS) $(NC4) $(CMIP6) $(GSW) -fno-second-underscore -ffree-line-length-256 $(OMP) 22 | 23 | INSTALL=$(HOME)/local/bin 24 | INSTALL_MAN=$(HOME)/local/man 25 | -------------------------------------------------------------------------------- /Macrolib/macro.ifort_ursus: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # !! $Rev$ 3 | # !! $Date$ 4 | # !! $Id$ 5 | # !!-------------------------------------------------------------- 6 | # 7 | NCDF = -I/usr/local/include -L/usr/local/lib -lnetcdf 8 | 9 | F90=ifort 10 | MPF90=ifort 11 | OMP= 12 | #OMP=-openmp 13 | #NC4 = -D key_netcdf4 14 | NC4 = 15 | 16 | #CMIP6 = -D key_CMIP6 17 | CMIP6 = 18 | 19 | GSW= 20 | #GSW=-D key_GSW 21 | GSWLIB= 22 | #GSWLIB=-lgsw 23 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian 24 | 25 | INSTALL=$(HOME)/bin 26 | INSTALL_MAN=$(HOME)/man 27 | -------------------------------------------------------------------------------- /Macrolib/macro.nymphea: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS : Nymphea (OSF1) 2 | # !! $Rev$ 3 | # !! $Date$ 4 | # !! $Id$ 5 | # !!-------------------------------------------------------------- 6 | # 7 | NCDF = -I/home/nymphea/services/bibli/netcdf-3.6.0/include -L/home/nymphea/services/bibli/netcdf-3.6.0/lib -lnetcdf 8 | 9 | OMP = 10 | #NC4 = -D key_netcdf4 11 | NC4 = 12 | 13 | #CMIP6 = -D key_CMIP6 14 | CMIP6 = 15 | 16 | GSW= 17 | #GSW=-D key_GSW 18 | GSWLIB= 19 | #GSWLIB=-lgsw 20 | 21 | F90=f90 22 | FFLAGS= $(NC4) $(CMIP6) $(GSW) -convert big_endian -assume byterecl $(NCDF) $(OMP) 23 | 24 | INSTALL=$(HOME)/bin 25 | -------------------------------------------------------------------------------- /Macrolib/macro.esmtools: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # 3 | # Joakim Kjellsson, GEOMAR, March 2019 4 | # 5 | 6 | NCDF = -I/$(NEMO_NETCDF_DIR)/include/ -I/$(NEMO_HDF5_DIR)/include/ 7 | LIBS = -L/$(NEMO_NETCDF_DIR)/lib/ -L/$(NEMO_HDF5_DIR)/lib/ -lnetcdff -lnetcdf 8 | NC4 = -D key_netcdf4 9 | 10 | #CMIP6 = -D key_CMIP6 11 | CMIP6 = 12 | 13 | GSW= 14 | #GSW=-D key_GSW 15 | GSWLIB= 16 | #GSWLIB=-lgsw 17 | 18 | F90=$(FC) 19 | MPF90= 20 | #OMP=-mp=nonuma 21 | OMP= 22 | OPT=-O3 23 | FFLAGS= $(OPT) -fpp $(NCDF) $(LIBS) $(NC4) $(CMIP6) $(GSW) $(OMP) 24 | LMPI=-lmpich 25 | 26 | INSTALL=../../../bin/ 27 | INSTALL_MAN=../../../man/ 28 | 29 | -------------------------------------------------------------------------------- /Macrolib/macro.ftn_hlrn_nc4: -------------------------------------------------------------------------------- 1 | # module load cray-netcdf cray-hdf5 2 | 3 | LIBS = -L/sw/dataformats/szip/2.1/smp1/intel/lib/ -lhdf5 -lhdf5_fortran -lnetcdf -lnetcdff -lhdf5_hl -lhdf5hl_fortran -lz 4 | NC4 = -D key_netcdf4 5 | #CMIP6 = -D key_CMIP6 6 | CMIP6 = 7 | 8 | GSW= 9 | #GSW=-D key_GSW 10 | GSWLIB= 11 | #GSWLIB=-lgsw 12 | 13 | F90=ftn -e F # force preprocessor irrespective of capitalization of file name 14 | # extension 15 | 16 | #OMP=-mp=nonuma 17 | OMP= 18 | FFLAGS= $(NC4) $(CMIP6) $(GSW) -O 2 $(NCDF) $(LIBS) $(OMP) 19 | LMPI=-lmpich 20 | 21 | INSTALL=$(HOME)/local/bin/ 22 | INSTALL_MAN=$(HOME)/local/man/ 23 | -------------------------------------------------------------------------------- /Macrolib/macro.rhodes: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS on RHODES.IDRIS.FR (SGI Origin 2100) 2 | # !! $Rev$ 3 | # !! $Date$ 4 | # !! $Id$ 5 | # !!-------------------------------------------------------------- 6 | # 7 | NCDF = -I/usr/local/pub/netcdf-3.6.1/include -L/usr/local/pub/netcdf-3.6.1/lib -lnetcdf 8 | 9 | F90=f90 10 | MPF90=f90 11 | 12 | OMP= 13 | #NC4 = -D key_netcdf4 14 | NC4 = 15 | 16 | #CMIP6 = -D key_CMIP6 17 | CMIP6 = 18 | 19 | GSW= 20 | #GSW=-D key_GSW 21 | GSWLIB= 22 | #GSWLIB=-lgsw 23 | FFLAGS= -O2 $(NC4) $(CMIP6) $(GSW) -mips4 -bytereclen $(NCDF) -bytereclen $(OMP) 24 | 25 | INSTALL=$(HOME_BIS)/CDFTOOLS-2.1/ 26 | 27 | 28 | -------------------------------------------------------------------------------- /Macrolib/macro.conda: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # -------------------------------------------------------------- 3 | # 4 | NCDF = -I$(CONDA_PREFIX)/include -L$(CONDA_PREFIX)/lib -lnetcdff -lnetcdf 5 | 6 | NC4= -D key_netcdf4 7 | #CMIP6 = -D key_CMIP6 8 | CMIP6 = 9 | 10 | GSW= 11 | #GSW=-D key_GSW 12 | GSWLIB= 13 | #GSWLIB=-lgsw 14 | 15 | 16 | #F90=gfortran -v 17 | F90=gfortran 18 | MPF90= 19 | #OMP=-fopenmp 20 | OMP= 21 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -fPIC -Wl,-rpath-link,$(CONDA_PREFIX)/lib -fno-second-underscore -ffree-line-length-256 $(OMP) 22 | LMPI=-lmpich 23 | 24 | INSTALL=$(WORKDIR)/bin 25 | INSTALL_MAN=$(WORKDIR)/man 26 | -------------------------------------------------------------------------------- /Macrolib/macro.p630: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS : AIX (p630) 2 | # !! $Rev$ 3 | # !! $Date$ 4 | # !! $Id$ 5 | # !!-------------------------------------------------------------- 6 | # 7 | NCDF = -I/usr/local/netcdf-3.6.0-p1/include -L/usr/local/netcdf-3.6.0-p1/lib -lnetcdf 8 | 9 | F90=xlf90 10 | MPF90=mpxlf90_r 11 | OMP= qsmp=omp 12 | #OMP=-qopenmp 13 | 14 | #NC4 = -D key_netcdf4 15 | NC4 = 16 | 17 | #CMIP6 = -D key_CMIP6 18 | CMIP6 = 19 | 20 | GSW= 21 | #GSW=-D key_GSW 22 | GSWLIB= 23 | #GSWLIB=-lgsw 24 | FFLAGS= -O4 $(NC4) $(CMIP6) $(GSW) -qsuffix=f=f90 -bmaxdata:500000000 $(NCDF) -q64 -qsave $(OMP) 25 | 26 | INSTALL=/usr/local/bin 27 | 28 | -------------------------------------------------------------------------------- /DEV_TOOLS/cdf_classes.txt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for line in $( cat $0 | grep -v '^#' | grep -v '^ ' | awk '{print $0}' ) ; do 3 | echo $line 4 | grep -e "@class $line" *90 5 | echo ==== 6 | done 7 | exit 8 | 9 | Equation_of_state 10 | ice_shelf_processing 11 | file_informations 12 | file_operations 13 | passive_tracer 14 | ensemble_processing 15 | statistics 16 | data_transformation 17 | transport 18 | integration 19 | mixed_layer 20 | mask 21 | bottom 22 | derived_fields 23 | energy_diagnostics 24 | forcing 25 | ice_diagnostics 26 | iceberg_processing 27 | miscellaneous 28 | obsolete 29 | preprocessing 30 | second_order_moments 31 | system 32 | 33 | -------------------------------------------------------------------------------- /Macrolib/macro.ifort_locean: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev$ 3 | # $Date$ 4 | # -------------------------------------------------------------- 5 | # 6 | 7 | NCDF = -I/opt/netcdf45/ifort15/include -L /opt/netcdf45/ifort15/lib -lnetcdf -lnetcdff 8 | 9 | NC4= -D key_netcdf4 10 | #CMIP6 = -D key_CMIP6 11 | CMIP6 = 12 | 13 | GSW= 14 | #GSW=-D key_GSW 15 | GSWLIB= 16 | #GSWLIB=-lgsw 17 | 18 | F90=ifort 19 | MPF90=mpif90 20 | OMP= 21 | #OMP=-openmp 22 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -CB -fpe0 -g -traceback -ftrapuv 23 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) $(OMP) 24 | LMPI=-lmpich 25 | 26 | INSTALL=$(HOME)/bin 27 | INSTALL_MAN=$(HOME)/man 28 | -------------------------------------------------------------------------------- /Macrolib/macro.icm: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev: 608 $ 3 | # $Date: 2012-07-03 15:29:11 +0200 (Tue, 03 Jul 2012) $ 4 | # -------------------------------------------------------------- 5 | # 6 | NCDF = -I/home/nhoareau/netcdf-ifort/include -L/home/nhoareau/netcdf-ifort/lib -lnetcdf 7 | 8 | F90=ifort 9 | MPF90=mpif90 10 | OMP= 11 | #OMP=-openmp 12 | #NC4 = -D key_netcdf4 13 | NC4 = 14 | 15 | #CMIP6 = -D key_CMIP6 16 | CMIP6 = 17 | 18 | GSW= 19 | #GSW=-D key_GSW 20 | GSWLIB= 21 | #GSWLIB=-lgsw 22 | 23 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(OMP) 24 | LMPI= 25 | 26 | INSTALL=$(HOME)/bin 27 | INSTALL_MAN=$(HOME)/man 28 | -------------------------------------------------------------------------------- /Macrolib/macro.sx8: -------------------------------------------------------------------------------- 1 | #Makefile for CDFTOOLS : SX8 (brodie) 2 | # !! $Rev$ 3 | # !! $Date$ 4 | # !! $Id$ 5 | # !!-------------------------------------------------------------- 6 | 7 | # 8 | MPF90 = sxmpif90 9 | F90 = sxf90 10 | 11 | #- 12 | NCDF = -I/SXlocal/pub/netCDF/netCDF-3.6.1/include -L/SXlocal/pub/netCDF/netCDF-3.6.1/lib -lnetcdf 13 | OMP= 14 | #OMP= -P openmp 15 | #NC4 = -D key_netcdf4 16 | NC4 = 17 | 18 | #CMIP6 = -D key_CMIP6 19 | CMIP6 = 20 | 21 | GSW= 22 | #GSW=-D key_GSW 23 | GSWLIB= 24 | #GSWLIB=-lgsw 25 | 26 | FFLAGS=$(NCDF) $(NC4) $(CMIP6) $(GSW) -dW -sx8 -C vopt -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 -L transform $(OMP) 27 | 28 | INSTALL=./ 29 | 30 | -------------------------------------------------------------------------------- /Macrolib/macro.porzig: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev: 95 $ 3 | # $Date: 2007-09-18 11:00:06 +0200 (Tue, 18 Sep 2007) $ 4 | # -------------------------------------------------------------- 5 | # 6 | #NCDF = -I/usr/local/include -L/usr/local/lib -lnetcdf 7 | NCDF = -I/export/home/services/netcdf-3.6.0-p1/include -L/export/home/services/netcdf-3.6.0-p1/lib -lnetcdf 8 | 9 | F90=ifort 10 | MPF90=ifort 11 | OMP= 12 | #OMP=-openmp 13 | 14 | #NC4 = -D key_netcdf4 15 | NC4 = 16 | 17 | #CMIP6 = -D key_CMIP6 18 | CMIP6 = 19 | 20 | GSW= 21 | #GSW=-D key_GSW 22 | GSWLIB= 23 | #GSWLIB=-lgsw 24 | 25 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(OMP) 26 | LMPI=-lmpi 27 | INSTALL=$(HOME)/bin 28 | -------------------------------------------------------------------------------- /Macrolib/macro.vayu: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev: 608 $ 3 | # $Date: 2012-07-03 23:29:11 +1000 (Tue, 03 Jul 2012) $ 4 | # -------------------------------------------------------------- 5 | # 6 | #NCDF = -I/usr/local/include -L/usr/local/lib -lnetcdf 7 | NCDF = -I$(NETCDF_BASE)/include/Intel -L$(NETCDF_BASE)/lib/Intel -lnetcdf -lnetcdff 8 | 9 | F90=ifort 10 | MPF90=mpif90 11 | OMP= 12 | #OMP=-openmp 13 | #NC4 = -D key_netcdf4 14 | NC4 = 15 | 16 | #CMIP6 = -D key_CMIP6 17 | CMIP6 = 18 | 19 | GSW= 20 | #GSW=-D key_GSW 21 | GSWLIB= 22 | #GSWLIB=-lgsw 23 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(OMP) 24 | LMPI=-lmpich 25 | 26 | INSTALL=$(HOME)/bin 27 | INSTALL_MAN=$(HOME)/man 28 | -------------------------------------------------------------------------------- /Macrolib/macro.adastra_intel: -------------------------------------------------------------------------------- 1 | # macro.adastra for adastra at CINES 2 | # $Date: 2023-03-08 3 | # $Id: macro.jade 539 2011-07-11 10:33:35Z molines $ 4 | # load cray environment : 5 | # module load cpe/22.11 6 | # module load cray-hdf5-parallel/1.12.2.1 7 | # module load cray-netcdf-hdf5parallel/4.9.0.1 8 | # ------------------------------------------------------------- 9 | 10 | NCDF= -I$(NETCDF_DIR)/include/ -L$(NETCDF_DIR)/lib -lnetcdf -lnetcdff 11 | 12 | NC4=-Dkey_netcdf4 13 | CMIP6 = 14 | 15 | GSW= 16 | GSWLIB= 17 | 18 | F90=ifort 19 | MPF90=mpif90 20 | 21 | OMP= 22 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -fp-model precise $(OMP) 23 | 24 | LMPI=-lmpich 25 | 26 | INSTALL=$(WORKDIR)/bin 27 | INSTALL_MAN=$(WORKDIR)/man 28 | 29 | -------------------------------------------------------------------------------- /Macrolib/macro.vargas: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS : AIX (zahir) 2 | # !! $Rev: 82 $ 3 | # !! $Date: 2007-07-17 10:24:09 +0200 (Tue, 17 Jul 2007) $ 4 | # !! $Id: macro.zahir 82 2007-07-17 08:24:09Z molines $ 5 | # !!-------------------------------------------------------------- 6 | # 7 | NCDF= -lnetcdf 8 | 9 | F90=xlf90 10 | MPF90=mpxlf90_r 11 | #OMP= qsmp=omp 12 | OMP= 13 | #NC4 = -D key_netcdf4 14 | NC4 = 15 | 16 | #CMIP6 = -D key_CMIP6 17 | CMIP6 = 18 | 19 | GSW= 20 | #GSW=-D key_GSW 21 | GSWLIB= 22 | #GSWLIB=-lgsw 23 | 24 | #FFLAGS= -O4 $(NC4) $(CMIP6) $(GSW) -qsuffix=f=f90 $(NCDF) -q64 -qsave $(OMP) 25 | FDATE_FLAG= -brename:.fdate,.fdate_ 26 | FFLAGS= -O4 $(NC4) $(CMIP6) $(GSW) -qsuffix=f=f90 $(NCDF) -q64 $(OMP) 27 | 28 | INSTALL=./ 29 | 30 | -------------------------------------------------------------------------------- /Macrolib/macro.zahir: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS : AIX (zahir) 2 | # !! $Rev$ 3 | # !! $Date$ 4 | # !! $Id$ 5 | # !!-------------------------------------------------------------- 6 | # 7 | NCDF = -I/usr/local/pub/netcdf/include -L/usr/local/pub/netcdf/lib -lnetcdf 8 | NCDF= -I/usr/local/pub/netcdf/netcdf-3.5.0/include -L/usr/local/pub/netcdf/netcdf-3.5.0/lib -lnetcdf 9 | 10 | F90=xlf90 11 | MPF90=mpxlf90_r 12 | OMP= 13 | #OMP= qsmp=omp 14 | #NC4 = -D key_netcdf4 15 | NC4 = 16 | 17 | #CMIP6 = -D key_CMIP6 18 | CMIP6 = 19 | 20 | GSW= 21 | #GSW=-D key_GSW 22 | GSWLIB= 23 | #GSWLIB=-lgsw 24 | #FFLAGS= -O4 $(NC4) $(CMIP6) $(GSW) -qsuffix=f=f90 $(NCDF) -q64 -qsave $(OMP) 25 | FFLAGS= -O4 $(NC4) $(CMIP6) $(GSW) -qsuffix=f=f90 $(NCDF) -q64 $(OMP) 26 | 27 | INSTALL=./ 28 | 29 | -------------------------------------------------------------------------------- /DEV_TOOLS/tagnc4.tpl: -------------------------------------------------------------------------------- 1 | LOGICAL :: lnc4 = .FALSE. ! Use nc4 with chunking and deflation 2 | 3 | PRINT *,' usage : cdfvita U-file V_file T-file [-w W-file] [-geo ] [-cubic] [-nc4] ...' 4 | 5 | PRINT *,' [ -nc4 ] : Use netcdf4 output with chunking and deflation level 1' 6 | PRINT *,' This option is effective only if cdftools are compiled with' 7 | PRINT *,' a netcdf library supporting chunking and deflation.' 8 | 9 | CASE ( '-nc4' ) ; lnc4 = .TRUE. 10 | 11 | stypvar(ivar)%ichunk = (/npiglo,MAX(1,npjglo/30),1,1 /) 12 | ncout = create (cf_out, cf_tfil, npiglo, npjglo, nlev , ld_nc4=lnc4 ) 13 | ierr = createvar (ncout , stypvar, nvar, ipk, id_varout, ld_nc4=lnc4 ) 14 | -------------------------------------------------------------------------------- /Macrolib/macro.hplaptop: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev: 673 $ 3 | # $Date: 2013-06-03 10:54:29 +0200 (Mon, 03 Jun 2013) $ 4 | # -------------------------------------------------------------- 5 | # 6 | #NCDF = -I/usr/local/include -L/usr/local/lib -lnetcdf 7 | NCDF = -I/opt/netcdf/4.2-intel/include -L/opt/netcdf/4.2-intel/lib -lnetcdf -lnetcdff 8 | 9 | F90=ifort 10 | MPF90=mpif90 11 | OMP= 12 | #OMP=-openmp 13 | 14 | #NC4 = -D key_netcdf4 15 | NC4 = 16 | 17 | #CMIP6 = -D key_CMIP6 18 | CMIP6 = 19 | 20 | GSW= 21 | #GSW=-D key_GSW 22 | GSWLIB= 23 | #GSWLIB=-lgsw 24 | 25 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian -CB -fpe0 -g -traceback -ftrapuv $(OMP) 26 | #FFLAGS= -O $(NCDF)$(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(OMP) 27 | LMPI=-lmpich 28 | 29 | INSTALL=$(HOME)/bin 30 | INSTALL_MAN=$(HOME)/man 31 | -------------------------------------------------------------------------------- /Macrolib/macro.ifort_dell: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev$ 3 | # $Date$ 4 | # -------------------------------------------------------------- 5 | # 6 | NCDF = -I/usr/local/netcdf/include -L /usr/local/netcdf/lib -lnetcdf -lnetcdff 7 | 8 | #NCDF = -I/opt/netcdf-4.1/include -I /opt/hdf5-1.8.4/include -L /opt/hdf5-1.8.4/lib -L/opt/netcdf-4.1/lib -lnetcdf -lhdf5_hl -lhdf5 -lz 9 | 10 | NC4= -D key_netcdf4 11 | #CMIP6 = -D key_CMIP6 12 | CMIP6 = 13 | 14 | GSW= 15 | #GSW=-D key_GSW 16 | GSWLIB= 17 | #GSWLIB=-lgsw 18 | 19 | F90=ifort 20 | MPF90=mpif90 21 | OMP= 22 | #OMP=-openmp 23 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian -CB -fpe0 -g -traceback -ftrapuv 24 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(OMP) 25 | LMPI=-lmpich 26 | 27 | INSTALL=$(HOME)/bin 28 | INSTALL_MAN=$(HOME)/man 29 | -------------------------------------------------------------------------------- /Macrolib/macro.gfortran: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev: 522 $ 3 | # $Date: 2011-06-17 12:50:13 +0200 (Fri, 17 Jun 2011) $ 4 | # -------------------------------------------------------------- 5 | # 6 | #NETCDF_ROOT=/opt/netcdf-4.1.1-gfortran 7 | NETCDF_ROOT=/usr 8 | NCDF = -I$(NETCDF_ROOT)/include -L$(NETCDF_ROOT)/lib -lnetcdff -lnetcdf 9 | 10 | NC4= -D key_netcdf4 11 | #CMIP6 = -D key_CMIP6 12 | CMIP6 = 13 | 14 | GSW= 15 | #GSW=-D key_GSW 16 | GSWLIB= 17 | #GSWLIB=-lgsw 18 | 19 | 20 | #F90=gfortran -v 21 | F90=gfortran 22 | MPF90= 23 | #OMP=-fopenmp 24 | OMP= 25 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -fno-second-underscore -ffree-line-length-256 $(OMP) -fbounds-check -g 26 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -fno-second-underscore -ffree-line-length-256 $(OMP) 27 | LMPI=-lmpich 28 | 29 | INSTALL=$(WORKDIR)/bin 30 | INSTALL_MAN=$(WORKDIR)/man 31 | -------------------------------------------------------------------------------- /DOC/chkuserdone.ksh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | # $Rev$ 4 | # $Date$ 5 | # suppose that we run this script in $CDFTOOLS/DOC 6 | CDFTOOLS=../ 7 | 8 | grep subsection cdftools_user.tex | grep -v addcontent | grep underline | sed -e 's@\\subsection\*{\\underline{@@' -e 's/:}}//' \ 9 | -e 's/\\//g' | sort > list_man 10 | here=$(pwd) 11 | cd $CDFTOOLS 12 | ls -1 *90 | sed -e 's/.f90//' | sort > $here/list_prog 13 | cd $here 14 | 15 | n=01 16 | for f in $( cat list_prog ); do 17 | grep -q $f list_man 18 | if [ $? == 1 ] ; then 19 | printf "\n %02d %s \t %s \n " $n $f 'missing in manual' 20 | n=$(( n + 1 )) 21 | fi 22 | done 23 | printf "\n" 24 | 25 | for f in $( cat list_man ); do 26 | grep -q $f list_prog 27 | if [ $? == 1 ] ; then 28 | printf "%s \t %s \n \n" $f 'missing in CDFTOOLS ??' 29 | fi 30 | done 31 | 32 | \rm -f list_prog list_man 33 | 34 | -------------------------------------------------------------------------------- /Macrolib/macro.adastra_cray: -------------------------------------------------------------------------------- 1 | # macro.adastra for adastra at CINES 2 | # $Date: 2023-03-08 3 | # $Id: macro.jade 539 2011-07-11 10:33:35Z molines $ 4 | # load cray environment : 5 | # module purge 6 | # module load craype-x86-genoa 7 | # module load PrgEnv-cray 8 | # module load cpe/23.02 9 | # module load cray-hdf5-parallel/1.12.2.1 10 | # module load cray-netcdf-hdf5parallel/4.9.0.1 11 | # ------------------------------------------------------------- 12 | 13 | NCDF= -I$(NETCDF_DIR)/include/ -L$(NETCDF_DIR)/lib -lnetcdf -lnetcdff 14 | 15 | NC4=-Dkey_netcdf4 16 | CMIP6 = 17 | 18 | GSW=-D key_GSW 19 | GSWLIB=-L $(WORKDIR)/lib -lgsw 20 | 21 | F90=ftn 22 | MPF90=mpif90 23 | 24 | OMP=-h omp 25 | FFLAGS= -O2 $(NCDF) $(NC4) $(CMIP6) $(GSW) $(OMP) 26 | 27 | LMPI=-lmpich 28 | 29 | INSTALL=$(WORKDIR)/bin 30 | INSTALL_MAN=$(WORKDIR)/man 31 | 32 | -------------------------------------------------------------------------------- /Macrolib/macro.lgge: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev: 827 $ 3 | # $Date: 2015-05-26 17:02:02 +0200 (mar. 26 mai 2015) $ 4 | # -------------------------------------------------------------- 5 | # 6 | #NCDF = -I/usr/local/include -L/usr/local/lib -lnetcdf 7 | 8 | NCDF = -I/opt/netcdf-4.1/include -I /opt/hdf5-1.8.4/include -L /opt/hdf5-1.8.4/lib -L/opt/netcdf-4.1/lib -lnetcdf -lhdf5_hl -lhdf5 -lz 9 | 10 | NC4= -D key_netcdf4 11 | #CMIP6= -D key_CMIP6 12 | CMIP6= 13 | 14 | GSW= 15 | #GSW=-D key_GSW 16 | GSWLIB= 17 | #GSWLIB=-lgsw 18 | 19 | F90=ifort 20 | MPF90=mpif90 21 | #OMP=-openmp 22 | OMP= 23 | #FFLAGS= -O $(NCDF) $(NC4) -assume byterecl -convert big_endian -CB -fpe0 -g -traceback -ftrapuv $(OMP) 24 | FFLAGS= -O3 $(NCDF) $(CMIP6) $(GSW) $(NC4) -assume byterecl -convert big_endian $(OMP) 25 | LMPI=-lmpich 26 | 27 | 28 | INSTALL=$(HOME)/bin 29 | INSTALL_MAN=$(HOME)/man 30 | -------------------------------------------------------------------------------- /Macrolib/macro.mac: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev: 173 $ 3 | # $Date: 2008-03-17 11:42:21 +0100 (Mon, 17 Mar 2008) $ 4 | # -------------------------------------------------------------- 5 | # 6 | #NCDF = -I/usr/local/include -L/usr/local/lib -lnetcdf 7 | NCDF = -I/usr/local/netcdf-3.6.1/ifort/include -L /usr/local/netcdf-3.6.1/ifort/lib/ \ 8 | -I/opt/netcdf/include -L /opt/netcdf/lib/ \ 9 | -I/usr/local/include -L/usr/local/lib -lnetcdf 10 | 11 | F90=ifort 12 | MPF90=mpif90 13 | OMP= 14 | #OPM=-openmp 15 | 16 | #NC4 = -D key_netcdf4 17 | NC4 = 18 | 19 | #CMIP6 = -D key_CMIP6 20 | CMIP6 = 21 | 22 | GSW= 23 | #GSW=-D key_GSW 24 | GSWLIB= 25 | #GSWLIB=-lgsw 26 | 27 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(OMP) 28 | LMPI=-lmpich 29 | 30 | #INSTALL=$(HOME)/bin 31 | INSTALL=/usr/local/bin 32 | INSTALL_MAN=/usr/local/man 33 | -------------------------------------------------------------------------------- /Macrolib/macro.ifort_nesh_fe: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS : nesh-fe.rz.uni-kiel.de 2 | # 3 | # Note that at compile and at runtime you need an intel compiler, and compatible 4 | # netcdf and hdf5. At the time of writing this (April 2020), you could run the 5 | # following to have everything in place: 6 | # 7 | # $ module load intel17.0.4 netcdf4.4.1intel hdf5-1.8.19intel 8 | # 9 | 10 | # libs 11 | LIBS = \ 12 | -L$(HDF5_DIR)/lib -L$(NETCDF_DIR)/lib -I$(NETCDF_DIR)/include \ 13 | -lhdf5 -lnetcdf -lnetcdff -lhdf5_hl \ 14 | -L/lib64 -limf -lm -lz 15 | 16 | F90 = ifort 17 | OMP= 18 | #OMP=-openmp 19 | #NC4 = -D key_netcdf4 20 | NC4 = 21 | 22 | #CMIP6 = -D key_CMIP6 23 | CMIP6 = 24 | 25 | GSW= 26 | #GSW=-D key_GSW 27 | GSWLIB= 28 | #GSWLIB=-lgsw 29 | 30 | FFLAGS = -O $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(LIBS) $(OMP) 31 | 32 | INSTALL = $(HOME)/bin 33 | INSTALL_MAN = $(HOME)/man 34 | -------------------------------------------------------------------------------- /DEV_TOOLS/tagmodule.tpl: -------------------------------------------------------------------------------- 1 | !!====================================================================== 2 | !! *** MODULE *** 3 | !! < short_description> 4 | !!===================================================================== 5 | !! History : *** 3 | !!===================================================================== 4 | !! ** Purpose : 5 | !! 6 | !! ** Method : 7 | !! 8 | !! History : 4.0 : 03/2017 : J.M. Molines : 9 | !!---------------------------------------------------------------------- 10 | !!---------------------------------------------------------------------- 11 | !! routines : description 12 | !!---------------------------------------------------------------------- 13 | 14 | 15 | !!---------------------------------------------------------------------- 16 | !! CDFTOOLS_4.0 , MEOM 2017 17 | !! $Id$ 18 | !! Copyright (c) 2012, J.-M. Molines 19 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 20 | !!---------------------------------------------------------------------- 21 | -------------------------------------------------------------------------------- /Macrolib/macro.ifort_hlrn4_nc4: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev: 522 $ 3 | # $Date: 2011-06-17 12:50:13 +0200 (Fri, 17 Jun 2011) $ 4 | # -------------------------------------------------------------- 5 | # 6 | # Joakim Kjellsson, GEOMAR, March 2019 7 | # 8 | 9 | #NCDF = -I/usr/local/include -L/usr/local/lib -lnetcdf 10 | #NCDF = -l netcdf -l netcdff 11 | NCDF = -I/$(NETCDF_DIR)/include/ -I/$(HDF5_DIR)/include/ 12 | LIBS = -L/$(NETCDF_DIR)/lib/ -L/$(HDF5_DIR)/lib/ -lnetcdf -lnetcdff 13 | #NC4 = -D 14 | NC4 = -D key_netcdf4 15 | 16 | #CMIP6 = -D key_CMIP6 17 | CMIP6 = 18 | 19 | GSW= 20 | #GSW=-D key_GSW 21 | GSWLIB= 22 | #GSWLIB=-lgsw 23 | 24 | #F90=gfortran -v 25 | F90=ifort 26 | MPF90= 27 | #OMP=-mp=nonuma 28 | OMP= 29 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -fno-second-underscore -ffree-line-length-256 30 | FFLAGS= -O3 -fpp $(NCDF) $(LIBS) $(NC4) $(CMIP6) $(GSW) $(OMP) 31 | LMPI=-lmpich 32 | 33 | INSTALL=../../../bin/ 34 | INSTALL_MAN=../../../man/ 35 | 36 | -------------------------------------------------------------------------------- /Macrolib/macro.occigen2: -------------------------------------------------------------------------------- 1 | # macro.jade for jade at CINES 2 | # $Rev: 539 $ 3 | # $Date: 2011-07-11 12:33:35 +0200 (Mon, 11 Jul 2011) $ 4 | # $Id: macro.jade 539 2011-07-11 10:33:35Z molines $ 5 | # ------------------------------------------------------------- 6 | 7 | NCDF = -I$(NETCDF_INCDIR) -I$(NETCDFF_INCDIR) $(NETCDF_LDFLAGS) $(NETCDFF_LDFLAGS) 8 | 9 | #NC4= 10 | NC4=-Dkey_netcdf4 11 | #CMIP6 = -D key_CMIP6 12 | CMIP6 = 13 | 14 | GSW= 15 | #GSW=-D key_GSW 16 | GSWLIB= 17 | #GSWLIB=-lgsw 18 | 19 | F90=ifort 20 | MPF90=mpif90 21 | 22 | OMP= 23 | #OMP=-openmp 24 | # flag static is used to allow the use of CDFTOOLS in parallel with mpi_metamon 25 | #FFLAGS= -static -O $(NCDF) -assume byterecl -convert big_endian $(OMP) 26 | 27 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -fp-model precise $(OMP) 28 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian -CB -fpe0 -ftrapuv -traceback -g $(OMP) 29 | 30 | LMPI=-lmpich 31 | 32 | INSTALL=$(WORKDIR)/bin 33 | INSTALL_MAN=$(WORKDIR)/man 34 | -------------------------------------------------------------------------------- /Macrolib/macro.ifort: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev$ 3 | # $Date$ 4 | # -------------------------------------------------------------- 5 | # 6 | #NCDF = -I/usr/local/include -L/usr/local/lib -lnetcdf 7 | NCDF = -I/usr/local/netcdf-3.6.1/ifort/include -L /usr/local/netcdf-3.6.1/ifort/lib/ \ 8 | -I/opt/netcdf/include -L /opt/netcdf/lib/ \ 9 | -I/usr/local/include -L/usr/local/lib -lnetcdf 10 | 11 | NCDF = -I/opt/netcdf-4.1/include -I /opt/hdf5-1.8.4/include -L /opt/hdf5-1.8.4/lib -L/opt/netcdf-4.1/lib -lnetcdf -lhdf5_hl -lhdf5 -lz 12 | 13 | NC4= -D key_netcdf4 14 | #CMIP6 = -D key_CMIP6 15 | CMIP6 = 16 | 17 | GSW= 18 | #GSW=-D key_GSW 19 | GSWLIB= 20 | #GSWLIB=-lgsw 21 | 22 | F90=ifort 23 | MPF90=mpif90 24 | OMP= 25 | #OMP=-openmp 26 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian -CB -fpe0 -g -traceback -ftrapuv 27 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(OMP) 28 | LMPI=-lmpich 29 | 30 | INSTALL=$(HOME)/bin 31 | INSTALL_MAN=$(HOME)/man 32 | -------------------------------------------------------------------------------- /Macrolib/macro.meolkara: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev: 173 $ 3 | # $Date: 2008-03-17 11:42:21 +0100 (lun 17 mar 2008) $ 4 | # -------------------------------------------------------------- 5 | # 6 | NCDF_ROOT=/opt/netcdf/4.1.1 7 | 8 | #NCDF_ROOT=/opt/netcdf/4.1 9 | #HDF5_ROOT=/opt/hdf5/1.8.4 10 | #ZLIB_ROOT=opt/zlib/1.2.3 11 | 12 | NCDF = -I$(NCDF_ROOT)/include -L $(NCDF_ROOT)/lib/ \ 13 | -lnetcdf 14 | 15 | #HDF5 = -I$(HDF5_ROOT)/include -L$(HDF5_ROOT)/lib -lhdf5_hl -lhdf5 16 | #ZLIB = -I$(ZLIB_ROOT)/include -L$(ZLIB_ROOT)/lib -lz 17 | 18 | F90=ifort 19 | MPF90=mpif90 20 | OMP= 21 | #OMP=-openmp 22 | #NC4 = -D key_netcdf4 23 | NC4 = 24 | 25 | #CMIP6 = -D key_CMIP6 26 | CMIP6 = 27 | 28 | GSW= 29 | #GSW=-D key_GSW 30 | GSWLIB= 31 | #GSWLIB=-lgsw 32 | 33 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(OMP) 34 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) $(HDF5) $(ZLIB) -assume byterecl -convert big_endian 35 | 36 | LMPI=-lmpich 37 | 38 | INSTALL=$(HOME)/bin 39 | INSTALL_MAN=$(HOME)/man 40 | -------------------------------------------------------------------------------- /Macrolib/macro.bsc: -------------------------------------------------------------------------------- 1 | # macro.jade for jade at CINES 2 | # $Rev: 539 $ 3 | # $Date: 2011-07-11 12:33:35 +0200 (Mon, 11 Jul 2011) $ 4 | # $Id: macro.jade 539 2011-07-11 10:33:35Z molines $ 5 | # ------------------------------------------------------------- 6 | 7 | #NCDF = -I$(NETCDF_INCDIR) -I$(NETCDFF_INCDIR) $(NETCDF_LDFLAGS) $(NETCDFF_LDFLAGS) 8 | NCDF = -I$(NETCDF_INC) $(LDFLAGS) 9 | 10 | #NC4= 11 | NC4=-Dkey_netcdf4 12 | #CMIP6 = -D key_CMIP6 13 | CMIP6 = 14 | 15 | #GSW= 16 | GSW=-D key_GSW 17 | GSWLIB= -L$(WORKDIR)/lib -lgsw 18 | #GSWLIB=-lgsw 19 | 20 | F90=ifort 21 | MPF90=mpif90 22 | 23 | OMP= 24 | #OMP=-openmp 25 | # flag static is used to allow the use of CDFTOOLS in parallel with mpi_metamon 26 | #FFLAGS= -static -O $(NCDF) -assume byterecl -convert big_endian $(OMP) 27 | 28 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -fp-model precise $(OMP) 29 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian -CB -fpe0 -ftrapuv -traceback -g $(OMP) 30 | 31 | LMPI=-lmpich 32 | 33 | INSTALL=$(WORKDIR)/bin 34 | INSTALL_MAN=$(WORKDIR)/man 35 | -------------------------------------------------------------------------------- /Macrolib/macro.cal1: -------------------------------------------------------------------------------- 1 | # macro.jade for jade at CINES 2 | # $Rev: 539 $ 3 | # $Date: 2011-07-11 12:33:35 +0200 (Mon, 11 Jul 2011) $ 4 | # $Id: macro.jade 539 2011-07-11 10:33:35Z molines $ 5 | # ------------------------------------------------------------- 6 | 7 | NCDF = -I$(NETCDF_INCDIR) -I$(NETCDFF_INCDIR) $(NETCDF_LDFLAGS) $(NETCDFF_LDFLAGS) 8 | 9 | #NC4= 10 | NC4=-Dkey_netcdf4 11 | #CMIP6 = -D key_CMIP6 12 | CMIP6 = 13 | 14 | F90=ifort 15 | MPF90=mpif90 16 | 17 | OMP= 18 | #OMP=-openmp 19 | # flag static is used to allow the use of CDFTOOLS in parallel with mpi_metamon 20 | #FFLAGS= -static -O $(NCDF) -assume byterecl -convert big_endian $(OMP) 21 | 22 | FFLAGS= -O3 $(NCDF) $(NC4) $(CMIP6) -fp-model precise $(OMP) 23 | #FFLAGS= -O2 $(NCDF) $(NC4) $(CMIP6) -fp-model precise $(OMP) 24 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) -assume byterecl -convert big_endian -CB -fpe0 -ftrapuv -traceback -g $(OMP) 25 | 26 | LMPI=-lmpich 27 | 28 | INSTALL=$(WORKDIR)/bin 29 | INSTALL=/opt/modules/cdftools/bin 30 | INSTALL_MAN=$(WORKDIR)/man 31 | INSTALL_MAN=/opt/modules/cdftools/man 32 | -------------------------------------------------------------------------------- /Macrolib/macro.jean-zay: -------------------------------------------------------------------------------- 1 | # macro.jade for jean-zay @ IDRIS 2 | # $Rev: 539 $ 3 | # $Date: 2011-07-11 12:33:35 +0200 (Mon, 11 Jul 2011) $ 4 | # $Id: macro.jean-zay 539 2011-07-11 10:33:35Z molines $ 5 | # ------------------------------------------------------------- 6 | # On Jean-Zay if netcdf module are properly loaded, you only need to specify 7 | # -lnecdf -l netcdff as FFLAGS. 8 | NCDF = -lnetcdf -lnetcdff 9 | 10 | #NC4= 11 | NC4=-Dkey_netcdf4 12 | #CMIP6 = -D key_CMIP6 13 | CMIP6 = 14 | 15 | #GSW= 16 | GSW=-D key_GSW 17 | #GSWLIB= 18 | GSWLIB= -lgsw 19 | 20 | F90=ifort 21 | MPF90=mpif90 22 | 23 | #OMP= 24 | OMP=-qopenmp 25 | # flag static is used to allow the use of CDFTOOLS in parallel with mpi_metamon 26 | #FFLAGS= -static -O $(NCDF) -assume byterecl -convert big_endian $(OMP) 27 | 28 | FFLAGS= -O2 $(NCDF) $(NC4) $(CMIP6) $(GSW) $(GSW) -fp-model precise $(OMP) 29 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) $(GSW) -assume byterecl -convert big_endian -CB -fpe0 -ftrapuv -traceback -g $(OMP) 30 | 31 | LMPI=-lmpich 32 | 33 | INSTALL=$(WORKDIR)/bin 34 | INSTALL_MAN=$(WORKDIR)/man 35 | -------------------------------------------------------------------------------- /DOC/Makefile: -------------------------------------------------------------------------------- 1 | # $Rev$ 2 | # $Id$ 3 | # $Date$ 4 | #----------------------------------------------------------- 5 | TEX=latex 6 | CDFTOOLS=cdftools 7 | CDFTOOLSDIR=CDFTOOLS_2.1 8 | 9 | all: $(CDFTOOLS)_prog.dvi $(CDFTOOLS)_user.dvi index 10 | 11 | $(CDFTOOLS).dvi: $(CDFTOOLS).tex 12 | 13 | index: $(CDFTOOLS)_prog.dvi $(CDFTOOLS)_user.dvi 14 | makeindex $(CDFTOOLS)_user.idx 15 | makeindex $(CDFTOOLS)_prog.idx 16 | 17 | #pdf: $(CDFTOOLS)_user.pdf $(CDFTOOLS)_prog.pdf 18 | 19 | pdf: $(CDFTOOLS)_user.tex $(CDFTOOLS)_prog.tex 20 | pdflatex $(CDFTOOLS)_user.tex 21 | pdflatex $(CDFTOOLS)_prog.tex 22 | 23 | # to force recompilation of tex file when index is updated 24 | touch: 25 | touch *.tex 26 | 27 | clean: 28 | \rm -f *.dvi *.log *.aux *~ *.idx *.ind *.ilg *.toc 29 | 30 | commit: 31 | svn ci 32 | 33 | web: pdf 34 | hevea $(CDFTOOLS)_user.tex 35 | scp $(CDFTOOLS)_user.html molines@meolipc:/var/www/web/CDFTOOLS/cdftools-2.1.html 36 | scp $(CDFTOOLS)_user.hind molines@meolipc:/var/www/web/CDFTOOLS/cdftools-2.1.hind 37 | scp $(CDFTOOLS)_user.pdf molines@meolipc:/var/www/web/CDFTOOLS/cdftools-2.1.pdf 38 | -------------------------------------------------------------------------------- /Macrolib/macro.occigen: -------------------------------------------------------------------------------- 1 | # macro.jade for jade at CINES 2 | # $Rev: 539 $ 3 | # $Date: 2011-07-11 12:33:35 +0200 (Mon, 11 Jul 2011) $ 4 | # $Id: macro.jade 539 2011-07-11 10:33:35Z molines $ 5 | # ------------------------------------------------------------- 6 | 7 | #NCDF= -I/scratch/cnt0024/hmg2840/molines/include -L/scratch/cnt0024/hmg2840/molines/lib -lnetcdf -lnetcdff 8 | NCDF = -I$(NETCDF_INCDIR) -I$(NETCDFF_INCDIR) $(_NETCDF_LDFLAGS) $(NETCDFF_LDFLAGS) 9 | 10 | #NC4= 11 | NC4=-Dkey_netcdf4 12 | #CMIP6 = -D key_CMIP6 13 | CMIP6 = 14 | 15 | GSW= 16 | #GSW=-D key_GSW 17 | GSWLIB= 18 | #GSWLIB=-lgsw 19 | 20 | F90=ifort 21 | MPF90=mpif90 22 | # flag static is used to allow the use of CDFTOOLS in parallel with mpi_metamon 23 | #FFLAGS= -static -O $(NCDF) -assume byterecl -convert big_endian 24 | 25 | OMP= 26 | #OMP=-openmp 27 | FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -fp-model precise $(OMP) 28 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian -CB -fpe0 -ftrapuv -traceback -g 29 | 30 | LMPI=-lmpich 31 | 32 | INSTALL=$(WORKDIR)/bin 33 | INSTALL_MAN=$(WORKDIR)/man 34 | 35 | -------------------------------------------------------------------------------- /Macrolib/macro.ada: -------------------------------------------------------------------------------- 1 | # macro.ada for ada at IDRIS 2 | # $Rev$ 3 | # $Date$ 4 | # $Id$ 5 | # ------------------------------------------------------------- 6 | # 7 | 8 | F90=ifort 9 | MPF90=mpiifort 10 | 11 | # assume compiler wrapper is working for netcdf on ada 12 | 13 | #OMP = -openmp 14 | OMP = 15 | #NC4 = -D key_netcdf4 16 | NC4 = 17 | 18 | #CMIP6 = -D key_CMIP6 19 | CMIP6 = 20 | 21 | GSW= 22 | #GSW=-D key_GSW 23 | GSWLIB= 24 | #GSWLIB=-lgsw 25 | 26 | # flag static is used to allow the use of CDFTOOLS in parallel with mpi_metamon 27 | #FFLAGS= -O $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian -CB -fpe0 -g -traceback -ftrapuv $(OMP) 28 | 29 | #FFLAGS= -O2 $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(OMP) 30 | FFLAGS= -O2 $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian -fpe0 -CB -ftrapuv -traceback -g -fp-model precise -fp-model source $(OMP) 31 | #FFLAGS=-O2 $(NC4) $(CMIP6) $(GSW) -xSSE4.1 -ip -ftz -fpe3 -fno-alias -sox -assume byterecl -convert big_endian -fp-model precise -fp-model source $(OMP) 32 | 33 | INSTALL=$(WORKDIR)/bin 34 | INSTALL_MAN=$(WORKDIR)/man 35 | -------------------------------------------------------------------------------- /DEV_TOOLS/tagusage.tpl: -------------------------------------------------------------------------------- 1 | IF ( narg == 0 ) THEN 2 | PRINT *,' usage : 3 | PRINT *,' ' 4 | PRINT *,' PURPOSE :' 5 | PRINT *,' 6 | PRINT *,' ' 7 | PRINT *,' ARGUMENTS :' 8 | PRINT *,' 9 | PRINT *,' ' 10 | PRINT *,' OPTIONS :' 11 | PRINT *,' 12 | PRINT *,' ' 13 | PRINT *,' REQUIRED FILES :' 14 | PRINT *,' 15 | PRINT *,' ' 16 | PRINT *,' OUTPUT : ' 17 | PRINT *,' netcdf file : ', TRIM(cf_out) 18 | PRINT *,' variables : ', TRIM(cv_out),' ( )' 19 | PRINT *,' ' 20 | PRINT *,' SEE ALSO :' 21 | PRINT *,' 22 | PRINT *,' ' 23 | STOP 24 | ENDIF 25 | 26 | ijarg = 1 27 | DO WHILE ( ijarg <= narg ) 28 | CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 29 | SELECT CASE ( cldum ) 30 | CASE ( '-f' ) ; CALL getarg(ijarg, cf_uvwtfil ) ; ijarg=ijarg+1 31 | ! option 32 | CASE ( '-o' ) ; CALL getarg(ijarg, cf_out ) ; ijarg=ijarg+1 33 | CASE ( '-nc4' ) ; lnc4 = .TRUE. 34 | CASE DEFAULT ; PRINT *, ' ERROR : ', TRIM(cldum),' : unknown option.'; STOP 1 35 | END SELECT 36 | ENDDO 37 | 38 | -------------------------------------------------------------------------------- /DOC/chkguide.ksh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | 3 | # $Rev$ 4 | # $Date$ 5 | CDFTOOLS=../ 6 | 7 | grep subsection cdftools_prog.tex | grep -v addcontent | grep underline | sed -e 's@\\subsection\*{\\underline{@@' -e 's/}}//' \ 8 | -e 's/\\//g' | sed -e 's/^ //' | sed -e 's/^.*F/F/' | sed -e 's/^.*S/S/' | sort > list_man 9 | 10 | here=$(pwd) 11 | cd $CDFTOOLS 12 | grep FUNCTION cdfio.f90 | grep -v END | grep -v -e '!' | sed -e 's/^.*F/F/' | sort > tttmp 13 | grep FUNCTION eos.f90 | grep -v END | grep -v -e '!' | sed -e 's/^.*F/F/' | sort >> tttmp 14 | grep SUBROUTINE cdfio.f90 | grep -v END | grep -v -e '!' | sed -e 's/^.*S/S/' | sort >> tttmp 15 | grep SUBROUTINE eos.f90 | grep -v END | grep -v -e '!' | sed -e 's/^.*S/S/' | sort >> tttmp 16 | cat tttmp | sort > $here/list_prog ; \rm tttmp 17 | cd $here 18 | 19 | cat list_prog 20 | n=01 21 | for f in $( cat list_prog | awk '{ print $0 }' ); do 22 | echo $f 23 | # g=$( echo $f | awk '{print $2}' ) 24 | #echo $g 25 | # grep -q $g list_man 26 | # if [ $? == 1 ] ; then 27 | # printf "\n %02d %s \t %s \n " $n $f 'missing in manual' 28 | # n=$(( n + 1 )) 29 | # fi 30 | done 31 | printf "\n" 32 | exit 33 | 34 | for f in $( cat list_man ); do 35 | grep -q $f list_prog 36 | if [ $? == 1 ] ; then 37 | printf "%s \t %s \n \n" $f 'missing in CDFTOOLS ??' 38 | fi 39 | done 40 | 41 | \rm -f list_prog list_man 42 | 43 | -------------------------------------------------------------------------------- /Macrolib/make.macro_nesh20210212: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS : nesh-fe.rz.uni-kiel.de 2 | # 3 | # $ update 20210112 - fschwarzkopf@geomar.de 4 | # 5 | # module purge 6 | # module load intel/20.0.4 7 | # module load netcdf-c-intel/4.7.4 8 | # module load netcdf-cxx4-intel/4.3.1 9 | # module load netcdf-fortran-intel/4.5.3 10 | # module load hdf5-intel/1.10.7 11 | # 12 | # (Linked dynamically!) 13 | 14 | export HDF5_LIB=/gxfs_work1/gxfs_home_interim/sw/spack/spack0.16.0/usr/opt/spack/linux-rhel8-x86_64/intel-20.0.4/hdf5-1.10.7-lcktuaan4d3qee3fickmxh3fmzazahxe/lib 15 | export NETCDF_LIB=/gxfs_work1/gxfs_home_interim/sw/spack/spack0.16.0/usr/opt/spack/linux-rhel8-x86_64/intel-20.0.4/hdf5-1.10.7-lcktuaan4d3qee3fickmxh3fmzazahxe/lib 16 | export NETCDF_INC=/gxfs_work1/gxfs_home_interim/sw/spack/spack0.16.0/usr/opt/spack/linux-rhel8-x86_64/intel-20.0.4/netcdf-fortran-4.5.3-ebr6xnqufaqypadqtpvg7sp33wdg67ha/include 17 | 18 | # libs 19 | LIBS = \ 20 | -L$(HDF5_LIB) -L$(NETCDF_LIB) -I$(NETCDF_INC) \ 21 | -lhdf5 -lnetcdf -lnetcdff -lhdf5_hl -L/lib64 -limf -lm -lz 22 | 23 | F90 = ifort 24 | OMP= 25 | #OMP=-openmp 26 | NC4 = -D key_netcdf4 27 | #NC4 = 28 | 29 | #CMIP6 = -D key_CMIP6 30 | CMIP6 = 31 | 32 | GSW= 33 | #GSW=-D key_GSW 34 | GSWLIB= 35 | #GSWLIB=-lgsw 36 | 37 | FFLAGS = -O $(NC4) $(CMIP6) -assume byterecl -convert big_endian $(LIBS) $(OMP) 38 | 39 | INSTALL = ../bin 40 | INSTALL_MAN = ../man 41 | -------------------------------------------------------------------------------- /Macrolib/macro.meolkerg: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev: 173 $ 3 | # $Date: 2008-03-17 11:42:21 +0100 (lun 17 mar 2008) $ 4 | # -------------------------------------------------------------- 5 | # 6 | #NCDF = -I/opt/netcdf-4.1/include -L /opt/netcdf-4.1/lib/ -lnetcdf 7 | HDF5 = -I/opt/hdf5-1.8.4/include -L/opt/hdf5-1.8.4/lib -lhdf5_hl -lhdf5 8 | ZLIB = -I/opt/zlib-1.2.3/include -L/opt/zlib-1.2.3/lib -lz 9 | 10 | NCDF = -I/opt/netcdf/4.2-intel/include -L /opt/netcdf/4.2-intel/lib/ -lnetcdf -lnetcdff 11 | #NCDF = -I/opt/netcdf-4.1.1-ifort/include -L /opt/netcdf-4.1.1-ifort/lib/ \ 12 | # -lnetcdf 13 | #HDF5 = 14 | #ZLIB = 15 | #NC4 = 16 | NC4 = -Dkey_netcdf4 17 | 18 | #CMIP6 = -D key_CMIP6 19 | CMIP6 = 20 | 21 | GSW= 22 | #GSW=-D key_GSW 23 | GSWLIB= 24 | #GSWLIB=-lgsw 25 | 26 | F90=ifort 27 | MPF90=mpif90 28 | OMP= 29 | #OMP=-openmp 30 | FFLAGS= -O -fp-model precise $(NCDF) $(NC4) $(CMIP6) $(GSW) $(HDF5) $(ZLIB) -fp-model precise $(OMP) 31 | #FFLAGS= -O -fpe0 -CB -traceback -g -ftrapuv -fp-model precise $(NCDF) $(NC4) $(CMIP6) $(GSW) $(HDF5) $(ZLIB) -assume byterecl -convert big_endian 32 | #FFLAGS= -O -fpe0 -CB -traceback -g -ftrapuv $(NCDF) $(NC4) $(CMIP6) $(GSW) $(HDF5) $(ZLIB) 33 | #FFLAGS= -O -fpe0 -CB -traceback -g -ftrapuv $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian 34 | LMPI=-lmpich 35 | 36 | INSTALL=$(WORKDIR)/bin 37 | INSTALL_MAN=$(WORKDIR)/man 38 | -------------------------------------------------------------------------------- /Macrolib/macro.dahu: -------------------------------------------------------------------------------- 1 | # $Rev: 539 $ 2 | # $Date: 2022-10-25 $ 3 | # macro.dahu for dahu at GRICAD 4 | # Needs the installation of ifort with nix : 5 | # $ source /applis/site/nix.sh 6 | # $ nix-env -i -A nur.repos.gricad.intel-oneapi 7 | # $ source ~/.nix-profile/setvars.sh 8 | # and the activation of netcdf librairy : 9 | # $ . /home/mchekki/LibGlace/versions/modules/modules_rev4401cc7d_gnu6.3.0/init/bash 10 | # $ export MODULEPATH="/home/mchekki/LibGlace/modulefiles:$MODULEPATH" 11 | # $ module load netcdf/netcdf-4.7.2_intel21_hdf5_MPIO 12 | # 13 | # ------------------------------------------------------------- 14 | 15 | NCDF = -I$(NETCDF_DIR)/include -L$(NETCDF_DIR)/lib -lnetcdff -lnetcdf 16 | 17 | #NC4= 18 | NC4=-Dkey_netcdf4 19 | #CMIP6 = -D key_CMIP6 20 | CMIP6 = 21 | 22 | F90=ifort 23 | MPF90=mpif90 24 | 25 | OMP= 26 | #OMP=-openmp 27 | # flag static is used to allow the use of CDFTOOLS in parallel with mpi_metamon 28 | #FFLAGS= -static -O $(NCDF) -assume byterecl -convert big_endian $(OMP) 29 | 30 | FFLAGS= -O3 $(NCDF) $(NC4) $(CMIP6) -fp-model precise $(OMP) 31 | #FFLAGS= -O2 $(NCDF) $(NC4) $(CMIP6) -fp-model precise $(OMP) 32 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) -assume byterecl -convert big_endian -CB -fpe0 -ftrapuv -traceback -g $(OMP) 33 | 34 | LMPI=-lmpich 35 | 36 | INSTALL=$(WORKDIR)/bin 37 | INSTALL=/opt/modules/cdftools/bin 38 | INSTALL_MAN=$(WORKDIR)/man 39 | INSTALL_MAN=/opt/modules/cdftools/man 40 | -------------------------------------------------------------------------------- /Macrolib/macro.curie: -------------------------------------------------------------------------------- 1 | # macro.jade for jade at CINES 2 | # $Rev: 539 $ 3 | # $Date: 2011-07-11 12:33:35 +0200 (Mon, 11 Jul 2011) $ 4 | # $Id: macro.jade 539 2011-07-11 10:33:35Z molines $ 5 | # ------------------------------------------------------------- 6 | # 7 | #NCDF=-I/usr/local/netcdf-4.2_hdf5_parallel/include -L/usr/local/netcdf-4.2_hdf5_parallel/lib -lnetcdff -lnetcdf -L/usr/local/hdf5-1.8.9_parallel/lib -lhdf5_hl -lhdf5 -lhdf5 8 | NCDF = -I$(NETCDF_INCDIR) $(NETCDF_LDFLAGS) -lnetcdff 9 | 10 | #NC4 = 11 | NC4 = -D key_netcdf4 # define this key in order to compile cdftools with netcdf4 lib allowing for chunking and deflation 12 | #CMIP6 = -D key_CMIP6 13 | CMIP6 = 14 | 15 | GSW= 16 | #GSW=-D key_GSW 17 | GSWLIB= 18 | #GSWLIB=-lgsw 19 | 20 | F90=ifort 21 | MPF90=mpif90 22 | OMP= 23 | #OMP=-openmp 24 | # flag static is used to allow the use of CDFTOOLS in parallel with mpi_metamon 25 | #FFLAGS= -static -O $(NCDF) $(NC4) $(CMIP6) $(GSW)-assume byterecl -convert big_endian $(OMP) 26 | #FFLAGS= -O $(NCDF) -fpe0 -traceback -ftrapuv -g -CB $(NC4) $(CMIP6) $(GSW) -fp-model precise $(OMP) 27 | #FFLAGS= -O $(NCDF) -fpe0 -traceback -ftrapuv -g $(NC4) $(CMIP6) $(GSW) -fp-model precise $(OMP) 28 | FFLAGS= -O2 $(NCDF) $(NC4) $(CMIP6) $(GSW) -fp-model precise $(OMP) 29 | #FFLAGS= -O $(NCDF) -assume byterecl -convert big_endian $(NC4) $(CMIP6) $(GSW) $(OMP) 30 | LMPI=-lmpich 31 | 32 | INSTALL=$(WORKDIR)/bin 33 | INSTALL_MAN=$(WORKDIR)/man 34 | -------------------------------------------------------------------------------- /Macrolib/macro.irene: -------------------------------------------------------------------------------- 1 | # macro.jade for jade at CINES 2 | # $Rev: 539 $ 3 | # $Date: 2011-07-11 12:33:35 +0200 (Mon, 11 Jul 2011) $ 4 | # $Id: macro.jade 539 2011-07-11 10:33:35Z molines $ 5 | # ------------------------------------------------------------- 6 | # 7 | #NCDF=-I/usr/local/netcdf-4.2_hdf5_parallel/include -L/usr/local/netcdf-4.2_hdf5_parallel/lib -lnetcdff -lnetcdf -L/usr/local/hdf5-1.8.9_parallel/lib -lhdf5_hl -lhdf5 -lhdf5 8 | NCDF = -I$(NETCDFFORTRAN_INCDIR) $(NETCDFFORTRAN_LDFLAGS) 9 | 10 | #NC4 = 11 | NC4 = -D key_netcdf4 # define this key in order to compile cdftools with netcdf4 lib allowing for chunking and deflation 12 | #CMIP6 = -D key_CMIP6 13 | CMIP6 = 14 | 15 | GSW= 16 | #GSW=-D key_GSW 17 | GSWLIB= 18 | #GSWLIB=-lgsw 19 | 20 | F90=ifort 21 | MPF90=mpif90 22 | OMP= 23 | #OMP=-openmp 24 | # flag static is used to allow the use of CDFTOOLS in parallel with mpi_metamon 25 | #FFLAGS= -static -O $(NCDF) $(NC4) $(CMIP6) $(GSW)-assume byterecl -convert big_endian $(OMP) 26 | #FFLAGS= -O $(NCDF) -fpe0 -traceback -ftrapuv -g -CB $(NC4) $(CMIP6) $(GSW) -fp-model precise $(OMP) 27 | #FFLAGS= -O $(NCDF) -fpe0 -traceback -ftrapuv -g $(NC4) $(CMIP6) $(GSW) -fp-model precise $(OMP) 28 | FFLAGS= -O2 $(NCDF) $(NC4) $(CMIP6) $(GSW) -fp-model precise $(OMP) 29 | #FFLAGS= -O $(NCDF) -assume byterecl -convert big_endian $(NC4) $(CMIP6) $(GSW) $(OMP) 30 | LMPI=-lmpich 31 | 32 | INSTALL=$(WORKDIR)/bin 33 | INSTALL_MAN=$(WORKDIR)/man 34 | -------------------------------------------------------------------------------- /src/cdftools-end.pod: -------------------------------------------------------------------------------- 1 | 2 | =head1 LICENSE AND COPYRIGHT 3 | 4 | Copyright (C) 1998-2016 IGE-MEOM (Jean-Marc.Molines@univ-grenoble-alpes.fr ) 5 | 6 | This software is governed by the CeCILL license under French law and 7 | abiding by the rules of distribution of free software. You can use, 8 | modify and/ or redistribute the software under the terms of the CeCILL 9 | license as circulated by CEA, CNRS and INRIA at the following URL 10 | "http://www.cecill.info". 11 | 12 | As a counterpart to the access to the source code and rights to copy, 13 | modify and redistribute granted by the license, users are provided only 14 | with a limited warranty and the software's author, the holder of the 15 | economic rights, and the successive licensors have only limited 16 | liability. 17 | 18 | In this respect, the user's attention is drawn to the risks associated 19 | with loading, using, modifying and/or developing or reproducing the 20 | software by the user in light of its specific status of free software, 21 | that may mean that it is complicated to manipulate, and that also 22 | therefore means that it is reserved for developers and experienced 23 | professionals having in-depth computer knowledge. Users are therefore 24 | encouraged to load and test the software's suitability as regards their 25 | requirements in conditions enabling the security of their systems and/or 26 | data to be ensured and, more generally, to use and operate it in the 27 | same conditions as regards security. 28 | 29 | The fact that you are presently reading this means that you have had 30 | knowledge of the CeCILL license and that you accept its terms. 31 | -------------------------------------------------------------------------------- /Macrolib/macro.jade: -------------------------------------------------------------------------------- 1 | # macro.jade for jade at CINES 2 | # $Rev$ 3 | # $Date$ 4 | # $Id$ 5 | # ------------------------------------------------------------- 6 | # 7 | NCDF= -I/opt/software/SGI/netcdf/4.0/include -L/opt/software/SGI/netcdf/4.0/lib -lnetcdff -lnetcdf 8 | #NCDF= -I/opt/software/SGI/netcdf/4.1.3/include -L/opt/software/SGI/netcdf/4.1.3/lib -lnetcdff -lnetcdf 9 | #NCDF = -I/opt/software/SGI/netcdf/netcdf-4.2_hdf5_1.8.9/include -L/opt/software/SGI/netcdf/netcdf-4.2_hdf5_1.8.9/lib -lnetcdff -lnetcdf 10 | #HDF5 = -I/opt/software/SGI/hdf5/1.8.9/include -L/opt/software/SGI/hdf5/1.8.9/lib -lhdf5 -lhdf5_fortran 11 | #HDF5 = -I/opt/software/SGI/hdf5/1.8.9-intelmpi/lib/include -L/opt/software/SGI/hdf5/1.8.9-intelmpi/lib -lhdf5 -lhdf5_fortran 12 | 13 | F90=ifort 14 | MPF90=mpif90 15 | #OMP= -openmp 16 | OMP= 17 | #NC4 = -D key_netcdf4 18 | NC4 = 19 | 20 | #CMIP6 = -D key_CMIP6 21 | CMIP6 = 22 | 23 | GSW= 24 | #GSW=-D key_GSW 25 | GSWLIB= 26 | #GSWLIB=-lgsw 27 | 28 | # flag static is used to allow the use of CDFTOOLS in parallel with mpi_metamon 29 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian -CB -fpe0 -g -traceback -ftrapuv 30 | 31 | FFLAGS= -static -O2 $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian $(OMP) 32 | #FFLAGS= -O2 $(NC4) $(CMIP6) $(GSW) -xSSE4.1 -ip -ftz -fpe3 -fno-alias -sox $(NCDF) -assume byterecl -convert big_endian 33 | #FFLAGS= -static $(NC4) $(CMIP6) $(GSW) -O $(NCDF) -assume byterecl -convert big_endian -g -traceback -fpe0 -ftrapuv -CB 34 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -assume byterecl -convert big_endian -g -traceback -fpe0 -ftrapuv -CB 35 | 36 | LMPI=-lmpich 37 | 38 | #-O3 -xSSE4.1 -ip -ftz -fpe3 -fno-alias -sox 39 | 40 | INSTALL=$(WORKDIR)/bin 41 | INSTALL_MAN=$(WORKDIR)/man 42 | -------------------------------------------------------------------------------- /src/cdftools-begin.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | CDFTOOLS - diagnostics in Fortran 90 for NEMO model outputs 4 | 5 | =head1 PACKAGE DESCRIPTION 6 | 7 | C is a diagnostic package written in fortran 90 for the analysis of NEMO model output, initialized in the frame of the DRAKKAR project (https://www.drakkar-ocean.eu/). It is now available on GitHub under the CeCILL license (http://www.cecill.info/licences/Licence_CeCILL_V2-en.html). 8 | 9 | C web site : http://www.nemo-ocean.eu/ 10 | 11 | =head1 SYNOPSIS 12 | 13 | C is a collection of fortran program. Each program belonging to this collection is 14 | designed to perform some specific actions on NEMO output files, and generally provides another netcdf file as output. Output files follow the same CDF format as NEMO file, thus allowing for the building of a secondary data base (assuming that the primary data base is just the raw model output). 15 | 16 | This documentation is automatically produced by the concatenation of the C messages produced by each particular program when invoked without any argument. (Standard behaviour of all cdftools). In the documentation, we use a rather classical formalism, where mandatory arguments are just indicated on the command line and options are indicated between squared brackets [..]. 17 | 18 | Each program name starts with the 3 letters 'cdf' followed by a word related to the action performed by the tools. Example: C is used to compute the vertical velocity using the horizontal velocity field represented by its two components Ufile.nc and Vfile.nc. 19 | 20 | Better than a long speech, the following paragraphs describes each of the existing cdftools. C have been sorted out by classes in order to have a consistent documentation. 21 | 22 | 23 | -------------------------------------------------------------------------------- /Macrolib/macro.ifort_hlrn_nc4: -------------------------------------------------------------------------------- 1 | # Makefile for CDFTOOLS 2 | # $Rev: 522 $ 3 | # $Date: 2011-06-17 12:50:13 +0200 (Fri, 17 Jun 2011) $ 4 | # -------------------------------------------------------------- 5 | # 6 | # mscheinert@geomar.de 2015-11-04 Better use at HLRN for [hb]data" 7 | # 8 | # Currently Loaded Modulefiles: 9 | # 1) modules/3.2.10.3 6) craype-sandybridge 11) HLRNenv 16) pmi/5.0.9-1.0000.10911.0.0.ari 21) alps/5.2.1-2.0502.9041.11.6.ari 10 | # 2) eswrap/1.1.0-1.020200.1231.0 7) cray-mpich/7.2.5 12) intel/15.0.1.133 17) dmapp/7.0.1-1.0502.9501.5.219.ari 22) rca/1.0.0-2.0502.53711.3.127.ari 11 | # 3) switch/1.0-1.0502.54233.2.96.ari 8) moab/generic 13) cray-libsci/13.2.0 18) gni-headers/3.0-1.0502.9684.5.2.ari 23) PrgEnv-intel/5.2.40 12 | # 4) craype-network-aries 9) torque/generic 14) udreg/2.3.2-1.0502.9275.1.12.ari 19) xpmem/0.1-2.0502.55507.3.2.ari 24) cray-netcdf/4.3.3.1 13 | # 5) craype/2.4.2 10) sw.mpp1 15) ugni/5.0-1.0502.9685.4.24.ari 20) dvs/2.5_0.9.0-1.0502.1873.1.145.ari 25) cray-hdf5/1.8.14 14 | # 15 | # i.e. In most cases on [hb]login node: 16 | # 17 | # module sw PrgEnv-cray/5.2.82 PrgEnv-intel/5.2.40 18 | # module sw craype-ivybridge craype-sandybridge 19 | # module load cray-netcdf/4.3.3.1 20 | # module load cray-hdf5/1.8.14 21 | 22 | 23 | 24 | #NCDF = -I/usr/local/include -L/usr/local/lib -lnetcdf 25 | #NCDF = -l netcdf -l netcdff 26 | NCDF = 27 | LIBS = -L/sw/dataformats/szip/2.1/smp1/intel/lib/ -lhdf5 -lhdf5_fortran -lnetcdf -lnetcdff -lhdf5_hl -lhdf5hl_fortran -lz 28 | #NC4 = -D 29 | NC4 = -D key_netcdf4 30 | 31 | #CMIP6 = -D key_CMIP6 32 | CMIP6 = 33 | 34 | GSW= 35 | #GSW=-D key_GSW 36 | GSWLIB= 37 | #GSWLIB=-lgsw 38 | 39 | #F90=gfortran -v 40 | F90=ftn 41 | MPF90= 42 | #OMP=-mp=nonuma 43 | OMP= 44 | #FFLAGS= -O $(NCDF) $(NC4) $(CMIP6) $(GSW) -fno-second-underscore -ffree-line-length-256 45 | FFLAGS= -O3 -fpp $(NCDF) $(LIBS) $(NC4) $(CMIP6) $(GSW) $(OMP) 46 | LMPI=-lmpich 47 | 48 | INSTALL=../../../bin/ 49 | INSTALL_MAN=../../../man/ 50 | -------------------------------------------------------------------------------- /License/CDFTOOLSCeCILL.txt: -------------------------------------------------------------------------------- 1 | The following licence information concerns ONLY the CDFTOOLS package 2 | ======================================================================= 3 | 4 | Copyright IGE-MEOM (Jean-Marc.Molines@univ-grenoble-alpes.fr ) 5 | Contributors (alphabetic order ) : 6 | C.Q. Akuetevi, M. Balmaseda, E. Behrens, F. Castruccio, M. Chekki, 7 | P. Colombo, J. Deshayes, N. Djath, N. Ducousso, C. Dufour, R. Dussin, 8 | N. Ferry, T. Graham, F. Hernandez, Q. Jamet, J. Jouanno, N. Jourdain, M. Juza, 9 | A. Lecointre, S. Leroux, C. Lique, W. Llovel, G. Mainsant, P. Mathiot, A. Melet, 10 | X. Meunier, G. Moreau, N. Merino, W. Rath, J. Regidor, M. Scheinert, 11 | F. Schwarzkopf, A.M. Treguier, P. Verezemskaya 12 | 13 | This software is a computer program for analysis of NEMO model output 14 | produced in the frame of the DRAKKAR project. It is designed for the 15 | treatment of the NetCdf files produced by NEMO-DRAKKAR. 16 | 17 | This software is governed by the CeCILL license under French law and 18 | abiding by the rules of distribution of free software. You can use, 19 | modify and/ or redistribute the software under the terms of the CeCILL 20 | license as circulated by CEA, CNRS and INRIA at the following URL 21 | "http://www.cecill.info". 22 | 23 | As a counterpart to the access to the source code and rights to copy, 24 | modify and redistribute granted by the license, users are provided only 25 | with a limited warranty and the software's author, the holder of the 26 | economic rights, and the successive licensors have only limited 27 | liability. 28 | 29 | In this respect, the user's attention is drawn to the risks associated 30 | with loading, using, modifying and/or developing or reproducing the 31 | software by the user in light of its specific status of free software, 32 | that may mean that it is complicated to manipulate, and that also 33 | therefore means that it is reserved for developers and experienced 34 | professionals having in-depth computer knowledge. Users are therefore 35 | encouraged to load and test the software's suitability as regards their 36 | requirements in conditions enabling the security of their systems and/or 37 | data to be ensured and, more generally, to use and operate it in the 38 | same conditions as regards security. 39 | 40 | The fact that you are presently reading this means that you have had 41 | knowledge of the CeCILL license and that you accept its terms. 42 | -------------------------------------------------------------------------------- /src/namdom_template_75: -------------------------------------------------------------------------------- 1 | !----------------------------------------------------------------------- 2 | &namdom ! space and time domain (bathymetry, mesh, timestep) 3 | !----------------------------------------------------------------------- 4 | jpk = 75 5 | nn_bathy = 1 ! compute (=0) or read (=1) the bathymetry file 6 | rn_bathy = 0. ! value of the bathymetry. if (=0) bottom flat at jpkm1 7 | nn_closea = 0 ! remove (=0) or keep (=1) closed seas and lakes (ORCA) 8 | nn_msh = 0 ! create (=1) a mesh file or not (=0) 9 | rn_hmin = -3. ! min depth of the ocean (>0) or min number of ocean level (<0) 10 | rn_e3zps_min= 20. ! partial step thickness is set larger than the minimum of 11 | rn_e3zps_rat= 0.1 ! rn_e3zps_min and rn_e3zps_rat*e3t, with 0 (lonsta2,latsta2) 63 | !! and so on 64 | 65 | lonsta(1)=-43.0 66 | lonsta(2)=-31.3 67 | lonsta(3)=-12.65 68 | lonsta(4)=-8.7 69 | 70 | latsta(1)=60.6 71 | latsta(2)=58.9 72 | latsta(3)=40.33 73 | latsta(4)=40.33 74 | 75 | \end{verbatim} 76 | 77 | The model F gridpoints corresponding to the 4 ends ot the legs are computed using the same code as cdffindij. Then 78 | a broken line is computed using the same code as cdftransportiz. The indices of all the F-points are saved in the arrays isec and jsec. 79 | Their corresponding longitudes and latitudes are stored in nav\_lon and nav\_lat (NB : those are the lon and lat of the F points). If those 80 | arrays' size is $N$ (number of points), the others arrays' size is $N-1$ (number of segments). This is an example of the standard output 81 | with a ORCA025 run : 82 | 83 | \begin{verbatim} 84 | ------------------------------------------------------------ 85 | leg 1 start at -43.00N 60.60W and ends at -31.30N 58.90W 86 | corresponding to F-gridpoints( 986, 796) and (1026, 782) 87 | ------------------------------------------------------------ 88 | ------------------------------------------------------------ 89 | leg 2 start at -31.30N 58.90W and ends at -12.65N 40.33W 90 | corresponding to F-gridpoints(1026, 782) and (1098, 675) 91 | ------------------------------------------------------------ 92 | ------------------------------------------------------------ 93 | leg 3 start at -12.65N 40.33W and ends at -8.70N 40.33W 94 | corresponding to F-gridpoints(1098, 675) and (1114, 675) 95 | ------------------------------------------------------------ 96 | 97 | \end{verbatim} 98 | 99 | \noindent 100 | Once we have these list of F-gridpoints isec and jsec, we have to pick the values of $u$ or $v$ corresponding to the segment. 101 | If the segment is an horizontal one, we will pick a value for $v$ and $u=0$ and vice-versa. Hence the vozocrtx and vomecrty arrays 102 | in the output netcdf files will have empty lines, this is perfectly normal. We loop from F-point $1$ to $N-1$ and we define the current 103 | F-point as f(i,j). Four cases are investigated : 104 | 105 | \begin{itemize} 106 | \item horizontal segment, eastward : $v = v(i+1,j)$ and $u = 0$ 107 | \item horizontal segment, westward : $v = v(i,j)$ and $u = 0$ 108 | \item vertical segment, southward : $v = 0$ and $u = u(i,j)$ 109 | \item vertical segment, northward : $v = 0 $ and $u = u(i,j+1)$ 110 | \end{itemize} 111 | 112 | \noindent 113 | The $e1v$, $e2u$, $e3v$ and $e3u$ arrays are picked at the same points that $u$ and $v$. Also, $u = 0$ leads to $e2u = e3u = 0$ and vice-versa. 114 | The temperature and salinity are interpolated on the $u$ or $v$ point. In the bottom, if one value on the T-point is zero (land), the value is set to 115 | zero. 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | \end{document} -------------------------------------------------------------------------------- /src/cdfstatcoord.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfstatcoord 2 | !!====================================================================== 3 | !! *** PROGRAM cdfstatcoord *** 4 | !!===================================================================== 5 | !! ** Purpose : Compute statistics about the grid metric versus latitude 6 | !! 7 | !! ** Method : bins e1 and e2 by latitudes and takes the mean value 8 | !! of each bin 9 | !! 10 | !! History : 2.1 : 07/2007 : J.M. Molines : Original code (T. Penduff idea) 11 | !! 3.0 : 01/2011 : J.M. Molines : Doctor norm + Lic. 12 | !! : 4.0 : 03/2017 : J.M. Molines 13 | !!---------------------------------------------------------------------- 14 | USE cdfio 15 | USE modcdfnames 16 | !!---------------------------------------------------------------------- 17 | !! CDFTOOLS_4.0 , MEOM 2017 18 | !! $Id$ 19 | !! Copyright (c) 2017, J.-M. Molines 20 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 21 | !! @class statistics 22 | !!---------------------------------------------------------------------- 23 | IMPLICIT NONE 24 | 25 | INTEGER(KIND=4) :: narg, iargc,ijarg ! browse lines 26 | INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain 27 | INTEGER(KIND=4) :: ngood ! point counter 28 | 29 | REAL(KIND=4), PARAMETER :: pp_binsize=2. ! bin size 30 | REAL(KIND=4), PARAMETER :: pp_latmin=-80. ! minimum latitude 31 | REAL(KIND=4), PARAMETER :: pp_latmax=90. ! maximum latitude 32 | REAL(KIND=4) :: rlat, rlat1, rlat2 ! working variables 33 | REAL(kind=4), DIMENSION(:,:), ALLOCATABLE :: e1, e2, gphi, zmask ! metrics and mask 34 | 35 | REAL(KIND=8) :: de1mean, de2mean ! mean value of horiz metrics 36 | 37 | CHARACTER(LEN=256) :: cf_coo, cf_msk ! file names 38 | CHARACTER(LEN=256) :: cv_msk ! mask variable name 39 | CHARACTER(LEN=256) :: cldum ! mask variable name 40 | 41 | LOGICAL, DIMENSION(:,:), ALLOCATABLE :: lgood ! flag for point selection 42 | !!---------------------------------------------------------------------- 43 | CALL ReadCdfNames() 44 | cv_msk = cn_tmask 45 | 46 | narg = iargc() 47 | IF ( narg == 0 ) THEN 48 | PRINT *,' usage : cdfstatcoord -c COOR-file -m MSK-file [-v MSK-var ]' 49 | PRINT *,' ' 50 | PRINT *,' PURPOSE :' 51 | PRINT *,' Compute and displays statistics about grid metrics vs latitude.' 52 | PRINT *,' Bins e1 and e2 by latitude bins, and compute the mean of each bin.' 53 | PRINT *,' ' 54 | PRINT *,' ARGUMENTS :' 55 | PRINT *,' -c COOR-file : coordinates file with e1 e2 metrics' 56 | PRINT *,' -m MSK-file : mask file ' 57 | PRINT *,' ' 58 | PRINT *,' OPTIONS :' 59 | PRINT *,' [-v MSK-var] : mask variable name. Default is ', TRIM(cv_msk) 60 | PRINT *,' ' 61 | PRINT *,' REQUIRED FILES :' 62 | PRINT *,' none apart those requested on command line.' 63 | PRINT *,' ' 64 | PRINT *,' OUTPUT : ' 65 | PRINT *,' Standard output' 66 | STOP 67 | ENDIF 68 | 69 | ijarg=1 70 | DO WHILE (ijarg <= narg ) 71 | CALL getarg(ijarg, cldum) ; ijarg=ijarg+1 72 | SELECT CASE ( cldum ) 73 | CASE ( '-c' ) ; CALL getarg (ijarg, cf_coo) ; ijarg=ijarg+1 74 | CASE ( '-m' ) ; CALL getarg (ijarg, cf_msk) ; ijarg=ijarg+1 75 | CASE ( '-v' ) ; CALL getarg (ijarg, cv_msk) ; ijarg=ijarg+1 76 | CASE DEFAULT ; PRINT *,' ERROR : ',TRIM(cldum),' : unknown option.' ; STOP 99 77 | END SELECT 78 | ENDDO 79 | 80 | IF ( chkfile(cf_coo) .OR. chkfile(cf_msk) ) STOP 99 ! missing files 81 | 82 | npiglo= getdim (cf_coo, cn_x) 83 | npjglo= getdim (cf_coo, cn_y) 84 | 85 | PRINT *, 'npiglo = ', npiglo 86 | PRINT *, 'npjglo = ', npjglo 87 | 88 | ALLOCATE ( e1(npiglo,npjglo) , e2(npiglo,npjglo) ) 89 | ALLOCATE ( gphi(npiglo,npjglo), zmask(npiglo,npjglo), lgood(npiglo,npjglo) ) 90 | 91 | ! read grid metrics and latitude 92 | e1 = getvar(cf_coo, cn_ve1t, 1, npiglo, npjglo) 93 | e2 = getvar(cf_coo, cn_ve2t, 1, npiglo, npjglo) 94 | gphi = getvar(cf_coo, cn_gphit, 1, npiglo, npjglo) 95 | ! read zmask (1) 96 | zmask = getvar(cf_msk, cv_msk, 1, npiglo, npjglo) 97 | 98 | rlat = pp_latmin + pp_binsize/2. 99 | PRINT '(a)', 'Latitude e1mean e2mean e1/e2 npoints' 100 | PRINT '(a)', '-----------------------------------------------------------------' 101 | DO WHILE ( rlat <= pp_latmax ) 102 | rlat1 = rlat - pp_binsize/2. ; rlat2 = rlat + pp_binsize/2. 103 | lgood = .FALSE. 104 | WHERE ( rlat1 <= gphi .AND. gphi < rlat2 .AND. zmask /= 0 ) lgood=.TRUE. 105 | ngood = COUNT(lgood) 106 | IF ( ngood /= 0 ) THEN 107 | de1mean = SUM( e1, mask=lgood) / ngood 108 | de2mean = SUM( e2, mask=lgood) / ngood 109 | ELSE 110 | de1mean = -999. 111 | de2mean = -999. 112 | ENDIF 113 | PRINT '(f8.3, 3f15.3,i8)', rlat, de1mean, de2mean ,de1mean/de2mean, ngood 114 | rlat = rlat + pp_binsize 115 | ENDDO 116 | 117 | END PROGRAM cdfstatcoord 118 | -------------------------------------------------------------------------------- /src/cdfnamelist.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfnamelist 2 | !!====================================================================== 3 | !! *** PROGRAM cdfnamelist *** 4 | !!===================================================================== 5 | !! ** Purpose : Give informations on the namelist mechanism implemented 6 | !! in CDFTOOLS_3. 7 | !! CDFTOOLS_4.0 , MEOM 2017 8 | !! to change default file names, variable or dimension 9 | !! names. 10 | !! 11 | !! ** Method : 12 | !! 13 | !! History : 3.0 : 01/2011 : J.M. Molines : Original code 14 | !! : 4.0 : 03/2017 : J.M. Molines 15 | !!---------------------------------------------------------------------- 16 | USE modcdfnames 17 | !!---------------------------------------------------------------------- 18 | !! CDFTOOLS_4.0 , MEOM 2017 19 | !! $Id$ 20 | !! Copyright (c) 2017, J.-M. Molines 21 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 22 | !! @class file_informations 23 | !!---------------------------------------------------------------------- 24 | IMPLICIT NONE 25 | 26 | INTEGER(KIND=4) :: narg, iargc, ijarg 27 | 28 | CHARACTER(LEN=80) :: cldum 29 | !!---------------------------------------------------------------------- 30 | CALL ReadCdfNames() 31 | 32 | narg = iargc() 33 | 34 | IF ( narg == 0 ) THEN 35 | PRINT *,' usage : cdfnamelist [-i] [-p]' 36 | PRINT *,' ' 37 | PRINT *,' PURPOSE :' 38 | PRINT *,' Give information [-i option] on the namelist mechanism implemented ' 39 | PRINT *,' since CDFTOOLS v3. Write a namelist template [-p option] to initialize' 40 | PRINT *,' the mechanism.' 41 | PRINT *,' ' 42 | PRINT *,' Note also than since CDFTOOLS v4, the name of the mesh/mask files as' 43 | PRINT *,' well as the name of the coordinates file can be modified from the ' 44 | PRINT *,' default, setting corresponding environment variable :' 45 | PRINT *,' CDFT_MESH_HGR to change the default ',TRIM(cn_fhgr) 46 | PRINT *,' CDFT_MESH_ZGR to change the default ',TRIM(cn_fzgr) 47 | PRINT *,' CDFT_MASK to change the default ',TRIM(cn_fmsk) 48 | PRINT *,' CDFT_BASINS to change the default ',TRIM(cn_fbasins) 49 | PRINT *,' CDFT_COORD to change the default ',TRIM(cn_fcoo) 50 | PRINT *,' ' 51 | PRINT *,' ARGUMENTS :' 52 | PRINT *,' none' 53 | PRINT *,' ' 54 | PRINT *,' OPTIONS :' 55 | PRINT *,' [ -i ] : print informations ' 56 | PRINT *,' [ -p ] : write a template namelist.' 57 | PRINT *,' ' 58 | PRINT *,' REQUIRED FILES :' 59 | PRINT *,' none' 60 | PRINT *,' ' 61 | PRINT *,' OUTPUT : ' 62 | PRINT *,' with option -p, print a template namelist : PrintCdfNames.namlist' 63 | PRINT *,' ' 64 | STOP 65 | ENDIF 66 | 67 | ijarg = 1 68 | DO WHILE ( ijarg <= narg ) 69 | CALL getarg( ijarg, cldum ) ; ijarg = ijarg + 1 70 | SELECT CASE ( cldum ) 71 | CASE ( '-i' ) 72 | CALL InfoUseNamelist() 73 | CASE ( '-p' ) 74 | CALL PrintCdfNames() 75 | CASE DEFAULT 76 | PRINT *, TRIM(cldum),' : unknown option in cdfnamelist ' 77 | END SELECT 78 | END DO 79 | 80 | CONTAINS 81 | 82 | SUBROUTINE InfoUseNamelist() 83 | !!--------------------------------------------------------------------- 84 | !! *** ROUTINE InfoUseNamelist *** 85 | !! 86 | !! ** Purpose : Print detailed info on the use of namelist in 87 | !! CDFTOOLS_4.0 , MEOM 2017 88 | !! 89 | !!---------------------------------------------------------------------- 90 | PRINT *,' In CDFTOOLS_3 the variable names, dimension names, mesh_mask' 91 | PRINT *,' file names can be customized via a system of namelist.' 92 | PRINT *,' A call to ReadCdfNames at the begining of the program allows' 93 | PRINT *,' the update of the names used in the program.' 94 | PRINT *,' If there is no need for changing names, then it is not necessary' 95 | PRINT *,' to give a namelist, the default values are OK.' 96 | PRINT *,' ' 97 | PRINT *,' If you need to change any of the default values, then you can' 98 | PRINT *,' use the namelist system to make this change effective. Doing do' 99 | PRINT *,' some rules are to be followed for proper use.' 100 | PRINT *,' ' 101 | PRINT *,'NAMELIST EDITING' 102 | PRINT *,' To have a template of a CDFTOOLS_3 namelist, use the statement' 103 | PRINT *,' cdfnamelist -p ' 104 | PRINT *,' This will give you a template namelist (PrintCdfNames.namlist)' 105 | PRINT *,' that you have to customized for your application.' 106 | PRINT *,' Some comments are made within this namelist for particular blocks.' 107 | PRINT *,' ' 108 | PRINT *,'NAME AND LOCATION OF THE NAMELIST' 109 | PRINT *,' The default name of the namelist read by ReadCdfNames is ' 110 | PRINT *,' nam_cdf_names' 111 | PRINT *,' ReadCdfNames look for the namelist in the current directory (./)' 112 | PRINT *,' and, if not found there, in the $HOME/CDFTOOLS_cfg/ directory' 113 | PRINT *,' The name of the namelist can be changed setting the environment' 114 | PRINT *,' variable NAM_CDF_NAMES to the desired value.' 115 | PRINT *,' ' 116 | 117 | END SUBROUTINE InfoUseNamelist 118 | 119 | END PROGRAM cdfnamelist 120 | -------------------------------------------------------------------------------- /src/cdfzonalout.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfzonalout 2 | !!====================================================================== 3 | !! *** PROGRAM cdfzonalout *** 4 | !!===================================================================== 5 | !! ** Purpose : Output zonal mean/integral as ascii files 6 | !! 7 | !! ** Method : Read zonalmean or zonalsum file, determine 1D variable 8 | !! and dump them on the standard output. 9 | !! 10 | !! History : 2.1 : 02/2006 : J.M. Molines : Original code 11 | !! : 4.0 : 03/2017 : J.M. Molines 12 | !! 3.0 : 05/2011 : J.M. Molines : Doctor norm + Lic. 13 | !!---------------------------------------------------------------------- 14 | USE cdfio 15 | USE modcdfnames 16 | !!---------------------------------------------------------------------- 17 | !! CDFTOOLS_4.0 , MEOM 2017 18 | !! $Id$ 19 | !! Copyright (c) 2017, J.-M. Molines 20 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 21 | !! @class file_informations 22 | !!---------------------------------------------------------------------- 23 | IMPLICIT NONE 24 | 25 | INTEGER(KIND=4) :: jj, jvar, jt ! dummy loop index 26 | INTEGER(KIND=4) :: ivar ! variable counter 27 | INTEGER(KIND=4) :: narg, iargc ! command line 28 | INTEGER(KIND=4) :: ijarg ! command line 29 | INTEGER(KIND=4) :: npjglo, npt ! size of the domain 30 | INTEGER(KIND=4) :: nvarin, nvar ! variables count 31 | INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: ipki ! input ipk variables 32 | INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: id_varin ! input variables id's 33 | 34 | REAL(KIND=4), DIMENSION (:,:), ALLOCATABLE :: zdumlat ! latitude for i = north pole 35 | REAL(KIND=4), DIMENSION (:,:,:), ALLOCATABLE :: zv ! data values 36 | 37 | REAL(KIND=8), DIMENSION (:), ALLOCATABLE :: dtim ! time counter 38 | 39 | TYPE(variable), DIMENSION(:), ALLOCATABLE :: stypvar ! dummy structure 40 | 41 | CHARACTER(LEN=256) :: cf_zonal ! input file name 42 | CHARACTER(LEN=256) :: cldum ! working char variable 43 | CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: cv_names ! input variable names 44 | !!---------------------------------------------------------------------- 45 | CALL ReadCdfNames() 46 | 47 | narg= iargc() 48 | 49 | IF ( narg == 0 ) THEN 50 | PRINT *,' usage : cdfzonalout -f ZONAL-file' 51 | PRINT *,' ' 52 | PRINT *,' PURPOSE :' 53 | PRINT *,' This is a formatting program for zonal files, either mean or integral.' 54 | PRINT *,' It displays results on the standard output from the input zonal file.' 55 | PRINT *,' It only works with 1D zonal variables, skipping 2D variables, that' 56 | PRINT *,' cannot be easily displayed !' 57 | PRINT *,' ' 58 | PRINT *,' ARGUMENTS :' 59 | PRINT *,' -f ZONAL-file : input netcdf zonal file produced by one of the zonal' 60 | PRINT *,' tools.' 61 | PRINT *,' ' 62 | PRINT *,' REQUIRED FILES :' 63 | PRINT *,' none' 64 | PRINT *,' ' 65 | PRINT *,' OUTPUT : ' 66 | PRINT *,' - Standard output, structured in columns:' 67 | PRINT *,' J LAT ( zonal mean, var = 1--> nvar) ' 68 | PRINT *,' ' 69 | PRINT *,' SEE ALSO :' 70 | PRINT *,' cdfzonalmean, cdfzonalmeanvT, cdfzonalsum' 71 | PRINT *,' ' 72 | STOP 73 | ENDIF 74 | 75 | ijarg=1 76 | DO WHILE ( ijarg <= narg) 77 | CALL getarg(ijarg, cldum) ; ijarg=ijarg+1 78 | SELECT CASE ( cldum) 79 | CASE ('-f' ) ; CALL getarg (ijarg, cf_zonal) ; ijarg=ijarg+1 80 | CASE DEFAULT ; PRINT *,' ERROR : ',TRIM(cldum),' : unknown option.' ; STOP 99 81 | END SELECT 82 | ENDDO 83 | 84 | IF ( chkfile(cf_zonal) ) STOP 99 ! missing file 85 | 86 | nvarin = getnvar(cf_zonal) 87 | ALLOCATE ( cv_names(nvarin), ipki(nvarin), id_varin(nvarin), stypvar(nvarin) ) 88 | 89 | cv_names(:) = getvarname(cf_zonal, nvarin, stypvar ) 90 | ipki(:) = getipk (cf_zonal, nvarin ) 91 | 92 | ! Open standard output with reclen 2048 for avoid wrapping with ifort 93 | OPEN(6,FORM='FORMATTED',RECL=2048) 94 | ! look for 1D var ( f(lat) ) 95 | nvar = 0 96 | DO jvar = 1,nvarin 97 | ! skip variables such as nav_lon, nav_lat, time_counter deptht ... 98 | IF (ipki(jvar) == 0 .OR. ipki(jvar) > 1 ) THEN 99 | cv_names(jvar)='none' 100 | ELSE 101 | nvar = nvar + 1 ! count for elligible input variables 102 | id_varin(nvar) = jvar ! use indirect adressing for those variables 103 | ENDIF 104 | END DO 105 | 106 | WRITE(6,*) 'Number of 1D variables :', nvar 107 | DO jvar=1,nvar 108 | ivar=id_varin(jvar) 109 | WRITE(6,*) ' ',TRIM(cv_names(ivar)) 110 | ENDDO 111 | 112 | npjglo = getdim (cf_zonal,cn_y) 113 | npt = getdim (cf_zonal,cn_t) 114 | 115 | WRITE(6,*) 'npjglo =', npjglo 116 | WRITE(6,*) 'npt =', npt 117 | 118 | ! Allocate arrays 119 | ALLOCATE ( zv(1,npjglo,nvar), dtim(npt) ) 120 | ALLOCATE ( zdumlat(1,npjglo) ) 121 | 122 | zdumlat(:,:) = getvar (cf_zonal, cn_vlat2d, 1, 1, npjglo) 123 | dtim(:) = getvar1d(cf_zonal, cn_vtimec, npt ) 124 | 125 | DO jt = 1, npt ! time loop 126 | ! main elligible variable loop 127 | DO jvar = 1, nvar 128 | ivar = id_varin(jvar) 129 | zv(:,:,jvar) = getvar(cf_zonal, cv_names(ivar), 1, 1, npjglo, ktime=jt) 130 | END DO ! next variable 131 | 132 | WRITE(6,*) ' JT = ', jt, ' TIME = ', dtim(jt) 133 | WRITE(6,*) ' J LAT ', (TRIM(cv_names(id_varin(jvar))),' ',jvar=1,nvar) 134 | 135 | DO jj=npjglo,1,-1 136 | WRITE(6,*) jj, zdumlat(1,jj), zv(1,jj,1:nvar) 137 | ENDDO 138 | ENDDO 139 | 140 | 141 | END PROGRAM cdfzonalout 142 | -------------------------------------------------------------------------------- /src/cdf_domain_modif.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdf_domain_modif 2 | !!====================================================================== 3 | !! *** PROGRAM cdf_domain_modif *** 4 | !!===================================================================== 5 | !! ** Purpose : adjust scalar variable in (jpiglo, jpjglo, ... jperio) 6 | !! in an existing domain_cfg file, for instance obtained 7 | !! when extracting a sub area with ncks 8 | !! 9 | !! ** Method : READ and Write ... 10 | !! 11 | !! History : 4.0 : 03/2017 : J.M. Molines : 12 | !!---------------------------------------------------------------------- 13 | USE netcdf 14 | 15 | IMPLICIT NONE 16 | INTEGER(KIND=4) :: jperio, jpiglo, jpjglo, jpkglo 17 | INTEGER(KIND=4) :: jpisfcav, jpsco, jpzps, jpzco 18 | INTEGER(KIND=4) :: narg, ijarg, ncid, id, ierr 19 | 20 | LOGICAL :: ll_jperio = .FALSE. 21 | LOGICAL :: ll_jpiglo = .FALSE. 22 | LOGICAL :: ll_jpjglo = .FALSE. 23 | LOGICAL :: ll_jpkglo = .FALSE. 24 | LOGICAL :: ll_isfcav = .FALSE. 25 | LOGICAL :: ll_sco = .FALSE. 26 | LOGICAL :: ll_zps = .FALSE. 27 | LOGICAL :: ll_zco = .FALSE. 28 | 29 | 30 | CHARACTER(LEN=80) :: cf_domain , cldum 31 | 32 | !!---------------------------------------------------------------------- 33 | !! CDFTOOLS_4.0 , MEOM 2020 34 | !! $Id$ 35 | !! Copyright (c) 2020, J.-M. Molines 36 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 37 | !! @class domain_file 38 | !!---------------------------------------------------------------------- 39 | narg = iargc() 40 | 41 | IF ( narg == 0 ) THEN 42 | PRINT *,' usage : cdf_domain_modif -d DOMAIN_cfg [-jperio JPERIO] [-jpiglo JPIGLO] ...' 43 | PRINT *,' [-jpjglo JPJGLO] [-jpkglo JPKGLO ...]' 44 | PRINT *,' [-ln_isfcav LN_ISFCAV] [-ln_sco LN_SCO] ...' 45 | PRINT *,' [-ln_zps LN_ZPS ] [-ln_zco LN_ZCO]' 46 | PRINT *,' ' 47 | PRINT *,' PURPOSE :' 48 | PRINT *,' Adjust scalar variable in (jpiglo, jpjglo, jpkglo, jperio) and boolean' 49 | PRINT *,' variables (ln_ifscav, ln_sco, ln_zps, ln_zco) in an existing domain_cfg' 50 | PRINT *,' file, for instance obtained when extracting a sub area with ncks.' 51 | 52 | PRINT *,' ' 53 | PRINT *,' ARGUMENTS :' 54 | PRINT *,' -d DOMAIN_cfg : specify the domain_cfg file to work with' 55 | PRINT *,' ' 56 | PRINT *,' OPTIONS :' 57 | PRINT *,' -jperio JPERIO : pass the new value for jperio. If option not used,' 58 | PRINT *,' no changes.' 59 | PRINT *,' -jpiglo JPIGLO : pass the new value for jpiglo. If option not used,' 60 | PRINT *,' no changes.' 61 | PRINT *,' -jpjglo JPJGLO : pass the new value for jpjglo. If option not used,' 62 | PRINT *,' no changes.' 63 | PRINT *,' -jpkglo JPKGLO : pass the new value for jpkglo. If option not used,' 64 | PRINT *,' no changes.' 65 | PRINT *,' -ln_isfcav LN_ISFCAV : pass the new value for ln_isfcav ( 1 or 0 ).' 66 | PRINT *,' If option not used, no changes.' 67 | PRINT *,' -ln_sco LN_SCO : pass the new value for ln_sco ( 1 or 0 ).' 68 | PRINT *,' If option not used, no changes.' 69 | PRINT *,' -ln_zps LN_ZPS : pass the new value for ln_zps ( 1 or 0 ).' 70 | PRINT *,' If option not used, no changes.' 71 | PRINT *,' -ln_zco LN_ZCO : pass the new value for ln_zco ( 1 or 0 ).' 72 | PRINT *,' If option not used, no changes.' 73 | PRINT *,' ' 74 | PRINT *,' REQUIRED FILES :' 75 | PRINT *,' none' 76 | PRINT *,' ' 77 | PRINT *,' OUTPUT : ' 78 | PRINT *,' netcdf file : Input file is modified on the output.' 79 | PRINT *,' ' 80 | STOP 81 | ENDIF 82 | 83 | ijarg = 1 84 | DO WHILE ( ijarg <= narg ) 85 | CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 86 | SELECT CASE ( cldum ) 87 | CASE ( '-d' ) ; CALL getarg(ijarg, cf_domain ) ; ijarg=ijarg+1 88 | ! option 89 | CASE ( '-jperio' ) ; CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 ; READ(cldum,*) jperio ; ll_jperio=.TRUE. 90 | CASE ( '-jpiglo' ) ; CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 ; READ(cldum,*) jpiglo ; ll_jpiglo=.TRUE. 91 | CASE ( '-jpjglo' ) ; CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 ; READ(cldum,*) jpjglo ; ll_jpjglo=.TRUE. 92 | CASE ( '-jpkglo' ) ; CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 ; READ(cldum,*) jpkglo ; ll_jpkglo=.TRUE. 93 | 94 | CASE ( '-ln_isfcav' ) ; CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 ; READ(cldum,*) jpisfcav ; ll_isfcav=.TRUE. 95 | CASE ( '-ln_sco' ) ; CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 ; READ(cldum,*) jpsco ; ll_sco=.TRUE. 96 | CASE ( '-ln_zps' ) ; CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 ; READ(cldum,*) jpzps ; ll_zps=.TRUE. 97 | CASE ( '-ln_zco' ) ; CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 ; READ(cldum,*) jpzco ; ll_zco=.TRUE. 98 | CASE DEFAULT ; PRINT *, ' ERROR : ', TRIM(cldum),' : unknown option.'; STOP 1 99 | END SELECT 100 | ENDDO 101 | 102 | ierr = NF90_OPEN(cf_domain, NF90_WRITE,ncid) 103 | 104 | IF ( ll_jperio) THEN 105 | ierr = NF90_INQ_VARID(ncid,'jperio',id ) 106 | ierr = NF90_PUT_VAR(ncid,id,jperio) 107 | ENDIF 108 | IF ( ll_jpiglo) THEN 109 | ierr = NF90_INQ_VARID(ncid,'jpiglo',id ) 110 | ierr = NF90_PUT_VAR(ncid,id,jpiglo) 111 | ENDIF 112 | IF ( ll_jpjglo) THEN 113 | ierr = NF90_INQ_VARID(ncid,'jpjglo',id ) 114 | ierr = NF90_PUT_VAR(ncid,id,jpjglo) 115 | ENDIF 116 | IF ( ll_jpkglo) THEN 117 | ierr = NF90_INQ_VARID(ncid,'jpkglo',id ) 118 | ierr = NF90_PUT_VAR(ncid,id,jpkglo) 119 | ENDIF 120 | IF ( ll_isfcav) THEN 121 | ierr = NF90_INQ_VARID(ncid,'ln_isfcav',id ) 122 | ierr = NF90_PUT_VAR(ncid,id,jpisfcav) 123 | ENDIF 124 | IF ( ll_sco) THEN 125 | ierr = NF90_INQ_VARID(ncid,'ln_sco',id ) 126 | ierr = NF90_PUT_VAR(ncid,id,jpsco) 127 | ENDIF 128 | IF ( ll_zps) THEN 129 | ierr = NF90_INQ_VARID(ncid,'ln_zps',id ) 130 | ierr = NF90_PUT_VAR(ncid,id,jpzps) 131 | ENDIF 132 | IF ( ll_zco) THEN 133 | ierr = NF90_INQ_VARID(ncid,'ln_zco',id ) 134 | ierr = NF90_PUT_VAR(ncid,id,jpzco) 135 | ENDIF 136 | 137 | ierr = NF90_CLOSE(ncid) 138 | 139 | 140 | END PROGRAM cdf_domain_modif 141 | -------------------------------------------------------------------------------- /src/cdfinfo.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfinfo 2 | !!====================================================================== 3 | !! *** PROGRAM cdfinfo *** 4 | !!===================================================================== 5 | !! ** Purpose : Give very basic informations for Netcdf File 6 | !! 7 | !! ** Method : to be improved 8 | !! 9 | !! History : 2.1 : 09/2010 : J.M. Molines : Original code 10 | !! 3.0 : 01/2011 : J.M. Molines : Doctor norm + Lic. 11 | !! : 4.0 : 03/2017 : J.M. Molines 12 | !!---------------------------------------------------------------------- 13 | USE cdfio 14 | USE modcdfnames 15 | !!---------------------------------------------------------------------- 16 | !! CDFTOOLS_4.0 , MEOM 2017 17 | !! $Id$ 18 | !! Copyright (c) 2017, J.-M. Molines 19 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 20 | !! @class file_informations 21 | !!---------------------------------------------------------------------- 22 | IMPLICIT NONE 23 | 24 | INTEGER(KIND=4) :: jvar, jarg ! dummy loop index 25 | INTEGER(KIND=4) :: ierr ! working integer 26 | INTEGER(KIND=4) :: idep, idep_max ! possible depth index, maximum 27 | INTEGER(KIND=4) :: narg, iargc, ijarg ! 28 | INTEGER(KIND=4) :: npiglo, npjglo, npk ,npt ! size of the domain 29 | INTEGER(KIND=4) :: nvars ! Number of variables in a file 30 | INTEGER(KIND=4) :: npoints ! Number of points with VALUE 31 | INTEGER(KIND=4), DIMENSION(1) :: ikloc ! used for MINLOC 32 | 33 | REAL(KIND=4) :: zdep ! depth to look for 34 | REAL(KIND=4) :: zval ! value to lookfor 35 | REAL(KIND=4), DIMENSION(:), ALLOCATABLE :: zdept ! depth array 36 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: zv2d ! 2D working array 37 | 38 | CHARACTER(LEN=256) :: cf_in ! file name 39 | CHARACTER(LEN=256) :: cv_dep ! depth name 40 | CHARACTER(LEN=256) :: cv_var ! depth name 41 | CHARACTER(LEN=256) :: cldum ! dummy input variable 42 | CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: cv_names ! array of var name 43 | CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: clv_dep ! possible choices for dep dimension 44 | 45 | TYPE(variable), DIMENSION(:), ALLOCATABLE :: stypvar ! variable attributes 46 | 47 | LOGICAL :: ldep =.FALSE. ! flag for depth control 48 | LOGICAL :: lval =.FALSE. ! flag for value control 49 | !!---------------------------------------------------------------------- 50 | CALL ReadCdfNames() 51 | 52 | narg= iargc() 53 | 54 | IF ( narg == 0 ) THEN 55 | PRINT *,' usage : cdfinfo -f MODEL-file [-dep dep] [-val VAR-val] [-in VAR-name]' 56 | PRINT *,' ' 57 | PRINT *,' PURPOSE :' 58 | PRINT *,' Gives very basic information about the file given in arguments.' 59 | PRINT *,' ' 60 | PRINT *,' ARGUMENTS :' 61 | PRINT *,' model output file in netcdf.' 62 | PRINT *,' ' 63 | PRINT *,' OPTIONS :' 64 | PRINT *,' [-dep depth ] : return the nearest k index corresponding to depth ' 65 | PRINT *,' [-val VAR-val ] : return the number of points with VAR-val in a ' 66 | PRINT *,' VAR-name variable.' 67 | PRINT *,' [-in VAR-name ] : name of the variable for value check.' 68 | PRINT *,' ' 69 | PRINT *,' OUTPUT : ' 70 | PRINT *,' On standard ouput, gives the size of the domain, the depth ' 71 | PRINT *,' dimension name, the number of variables.' 72 | PRINT *,' ' 73 | STOP 74 | ENDIF 75 | 76 | ijarg=1 77 | cv_var='none' 78 | DO WHILE ( ijarg <= narg ) 79 | CALL getarg(ijarg, cldum) ; ijarg=ijarg+1 80 | SELECT CASE ( cldum ) 81 | CASE ( '-f' ) ; CALL getarg (ijarg, cf_in) ; ijarg=ijarg+1 82 | ! options 83 | CASE ( '-dep' ) ; CALL getarg (ijarg, cldum) ; ijarg=ijarg+1 ; READ(cldum,*) zdep ; ldep =.TRUE. 84 | CASE ( '-val' ) ; CALL getarg (ijarg, cldum) ; ijarg=ijarg+1 ; READ(cldum,*) zval ; lval =.TRUE. 85 | CASE ( '-in' ) ; CALL getarg (ijarg, cv_var); ijarg=ijarg+1 86 | CASE DEFAULT ; PRINT *, 'ERROR : ',TRIM(cldum),' : unknown option.' ; STOP 99 87 | END SELECT 88 | ENDDO 89 | 90 | IF ( chkfile(cf_in) ) STOP 99 ! missing file 91 | 92 | npiglo = getdim (cf_in,cn_x) 93 | npjglo = getdim (cf_in,cn_y) 94 | 95 | ! looking for npk among various possible name 96 | idep_max=8 97 | ALLOCATE ( clv_dep(idep_max) ) 98 | clv_dep(:) = (/cn_z,'z','sigma','nav_lev','levels','ncatice','icbcla','icbsect'/) 99 | idep=1 ; ierr=1000 100 | DO WHILE ( ierr /= 0 .AND. idep <= idep_max ) 101 | npk = getdim (cf_in, clv_dep(idep), cdtrue=cv_dep, kstatus=ierr) 102 | idep = idep + 1 103 | ENDDO 104 | 105 | IF ( ierr /= 0 ) THEN ! none of the dim name was found 106 | PRINT *,' assume file with no depth' 107 | npk=0 108 | ENDIF 109 | 110 | npt = getdim (cf_in,cn_t) 111 | 112 | PRINT *, 'npiglo =', npiglo 113 | PRINT *, 'npjglo =', npjglo 114 | PRINT *, 'npk =', npk 115 | PRINT *, 'npt =', npt 116 | 117 | PRINT *,' Depth dimension name is ', TRIM(cv_dep) 118 | 119 | nvars = getnvar(cf_in) 120 | PRINT *,' nvars =', nvars 121 | 122 | ALLOCATE (cv_names(nvars) ) 123 | ALLOCATE (stypvar(nvars) ) 124 | 125 | ! get list of variable names 126 | cv_names(:)=getvarname(cf_in, nvars, stypvar) 127 | 128 | DO jvar = 1, nvars 129 | PRINT *, 'variable# ',jvar,' is : ',TRIM(cv_names(jvar)) 130 | END DO 131 | 132 | IF ( ldep ) THEN 133 | ALLOCATE(zdept(npk) ) 134 | zdept = getdimvar (cf_in, npk) 135 | ikloc= MINLOC( ABS(zdept - zdep) ) 136 | PRINT * ,' NEAREST_K ',ikloc(1) 137 | ENDIF 138 | 139 | IF (lval ) THEN 140 | ALLOCATE( zv2d(npiglo, npjglo ) ) 141 | zv2d=getvar(cf_in, cv_var, 1, npiglo, npjglo) 142 | WHERE (zv2d /= zval ) 143 | zv2d = 0. 144 | ELSEWHERE 145 | zv2d = 1. 146 | END WHERE 147 | npoints = SUM(zv2d ) 148 | PRINT *,' VAR ', TRIM(cv_var),' : value ', zval,' : ', npoints 149 | ENDIF 150 | 151 | 152 | END PROGRAM cdfinfo 153 | -------------------------------------------------------------------------------- /src/cdfcoast.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfcoast 2 | !!====================================================================== 3 | !! *** PROGRAM cdfcoast *** 4 | !!===================================================================== 5 | !! ** Purpose : create a coast file from surface tmask 6 | !! 7 | !! History : 4.0 : 06/2022 : J.M. Molines 8 | !!---------------------------------------------------------------------- 9 | USE cdfio 10 | USE modcdfnames 11 | !!---------------------------------------------------------------------- 12 | !! CDFTOOLS_4.0 , MEOM 2022 13 | !! $Id$ 14 | !! Copyright (c) 2022, J.-M. Molines 15 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 16 | !! @class mask 17 | !!---------------------------------------------------------------------- 18 | IMPLICIT NONE 19 | 20 | INTEGER(KIND=4) :: ierr ! error status 21 | INTEGER(KIND=4) :: ji, jj, jw ! dummy loop index 22 | INTEGER(KIND=4) :: narg, iargc, ijarg ! command line 23 | INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain 24 | INTEGER(KIND=4) :: isum ! sum of the 9 tmask point 25 | INTEGER(KIND=4) :: ncout ! ncid of output file 26 | INTEGER(KIND=4) :: iwidth=1 ! width of coastal band 27 | INTEGER(KIND=4), DIMENSION(1) :: ipk, id_varout ! outptut variables : number of levels, 28 | 29 | INTEGER(KIND=2), DIMENSION(:,:), ALLOCATABLE :: itmask ! mask at jk level 30 | INTEGER(KIND=2), DIMENSION(:,:), ALLOCATABLE :: icoast ! masked cv_in at jk level 31 | 32 | CHARACTER(LEN=256) :: cf_out='coast.nc' ! output file name 33 | CHARACTER(LEN=256) :: cf_msk ! input mask file name 34 | CHARACTER(LEN=256) :: cldum ! dummy char var 35 | 36 | TYPE (variable), DIMENSION(1) :: stypvar ! output attribute 37 | 38 | LOGICAL :: lnc4 =.FALSE. ! use Netcdf4 chunking and deflation 39 | !!---------------------------------------------------------------------- 40 | CALL ReadCdfNames() 41 | 42 | narg = iargc() 43 | IF ( narg == 0 ) THEN 44 | PRINT *,' usage : cdfcoast -f MASK-file [-v MASK-var] [-nc4] [-o OUT-file] [-w width ] ' 45 | PRINT *,' ' 46 | PRINT *,' PURPOSE :' 47 | PRINT *,' This program is used to create a coastal mask file, in wich ocean' 48 | PRINT *,' points next to the coast are set to 1, 0 elsewhere. These points' 49 | PRINT *,' typically corresponds to runoff points.' 50 | PRINT *,' ' 51 | PRINT *,' ARGUMENTS :' 52 | PRINT *,' -f MASK-file : name of the mask file ' 53 | PRINT *,' ' 54 | PRINT *,' OPTIONS : ' 55 | PRINT *,' -v MASK-var : input netcdf mask variable.' 56 | PRINT *,' -w width : width (pixel) of the coastal band' 57 | PRINT *,' -nc4 : use netcdf4/Hdf5 chunking and deflation.' 58 | PRINT *,' -o OUT-file : name of coastal_mask file.[',TRIM(cf_out),']' 59 | PRINT *,' ' 60 | PRINT *,' REQUIRED FILES :' 61 | PRINT *,' none, all are given as arguments.' 62 | PRINT *,' ' 63 | PRINT *,' OUTPUT : ' 64 | PRINT *,' coastal.nc file unless -o option is used.' 65 | PRINT *,' Variable : coast_mask' 66 | STOP 67 | ENDIF 68 | 69 | ijarg = 1 70 | DO WHILE (ijarg <= narg) 71 | CALL getarg (ijarg, cldum ) ; ijarg = ijarg + 1 72 | SELECT CASE ( cldum) 73 | CASE ( '-f' ) ; CALL getarg(ijarg, cf_msk ) ; ijarg = ijarg + 1 74 | CASE ( '-v' ) ; CALL getarg(ijarg, cn_tmask ) ; ijarg = ijarg + 1 75 | CASE ( '-w' ) ; CALL getarg(ijarg, cldum ) ; ijarg = ijarg + 1 ; READ(cldum,*) iwidth 76 | CASE ( '-nc4' ) ; lnc4 = .true. 77 | CASE ( '-o' ) ; CALL getarg(ijarg, cf_out ) ; ijarg = ijarg + 1 78 | CASE DEFAULT ; PRINT *,' ERROR : ', TRIM(cldum),' : unknown option.' ; STOP 99 79 | END SELECT 80 | ENDDO 81 | 82 | IF ( chkfile(cf_msk) ) STOP 99 ! missing files 83 | 84 | ! get NEMO grid information 85 | npiglo = getdim (cf_msk,cn_x) 86 | npjglo = getdim (cf_msk,cn_y) 87 | 88 | PRINT *, 'npiglo = ', npiglo 89 | PRINT *, 'npjglo = ', npjglo 90 | 91 | ! Allocate arrays 92 | ALLOCATE( itmask(npiglo,npjglo) ) 93 | ALLOCATE( icoast(npiglo,npjglo) ) 94 | itmask(:,:) = getvar(cf_msk, cn_tmask, 1, npiglo, npjglo) 95 | icoast(:,:) = 0 96 | DO jw = 1, iwidth 97 | DO jj = 2, npjglo-1 98 | DO ji = 2, npiglo-1 99 | IF ( itmask(ji,jj) == 1 ) THEN 100 | isum=SUM(itmask(ji-1:ji+1, jj)) + SUM(itmask(ji, jj-1:jj+1)) 101 | ! check against 6 instead of 5 because central point (i,j) is 102 | ! counted twice 103 | IF ( isum /= 6 ) icoast(ji,jj) = icoast(ji,jj) + 1 104 | ENDIF 105 | ENDDO 106 | ENDDO 107 | WHERE (icoast == 1 ) itmask = 0 108 | ENDDO 109 | 110 | CALL CreateOutput 111 | ierr = putvar(ncout, id_varout(1), icoast, 1, npiglo, npjglo) 112 | 113 | ierr =closeout(ncout) 114 | 115 | CONTAINS 116 | 117 | SUBROUTINE CreateOutput 118 | !!--------------------------------------------------------------------- 119 | !! *** ROUTINE CreateOutput *** 120 | !! 121 | !! ** Purpose : Create netcdf output file(s) 122 | !! 123 | !! ** Method : Use stypvar global description of variables 124 | !! 125 | !!---------------------------------------------------------------------- 126 | REAL(KIND=8), DIMENSION(1) :: dltim 127 | !!---------------------------------------------------------------------- 128 | ipk = 1 129 | 130 | stypvar(1)%ichunk = (/npiglo,MAX(1,npjglo/30),1,1 /) 131 | stypvar(1)%cname = 'coast_mask' 132 | 133 | stypvar(1)%cunits = '1/0' 134 | stypvar(1)%rmissing_value = 9999. 135 | stypvar(1)%valid_min = 0. 136 | stypvar(1)%valid_max = 1. 137 | 138 | stypvar(1)%clong_name = 'Ocean points near the coast' 139 | 140 | stypvar(1)%cshort_name = 'coast_mask' 141 | 142 | stypvar(1)%conline_operation = 'N/A' 143 | stypvar(1)%caxis = 'TYX' 144 | stypvar(1)%cprecision = 'i2' 145 | 146 | ncout = create (cf_out, cf_msk, npiglo, npjglo, 0, ld_nc4=lnc4 ) 147 | ierr = createvar (ncout, stypvar, 1, ipk, id_varout, ld_nc4=lnc4 ) 148 | 149 | ierr = putheadervar(ncout, cf_msk, npiglo, npjglo, 0) 150 | dltim = 0.d0 151 | ierr = putvar1d(ncout, dltim, 1,'T') 152 | 153 | 154 | END SUBROUTINE CreateOutput 155 | 156 | END PROGRAM cdfcoast 157 | -------------------------------------------------------------------------------- /src/cdfcmp.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfcmp 2 | !!====================================================================== 3 | !! *** PROGRAM cdfcmp *** 4 | !!====================================================================== 5 | !! ** Purpose : Find the differences between one same variable in two different files 6 | !! Indicate where are located these differences 7 | !! Indicate the relative difference 8 | !! 9 | !! ** Method : Compare var1 and var2 10 | !! If it differs, print in standard output where are located diff 11 | !! Spatial sub-area restriction can be defined 12 | !! 13 | !! History : 3.0 ! 08/2012 A. Lecointre : Original code + Full Doctor form + Lic. 14 | !! : 4.0 : 03/2017 : J.M. Molines 15 | !!---------------------------------------------------------------------- 16 | USE cdfio 17 | USE modcdfnames 18 | !!---------------------------------------------------------------------- 19 | !! CDFTOOLS_4.0 , MEOM 2017 20 | !! $Id$ 21 | !! Copyright (c) 2017, J.-M. Molines 22 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 23 | !! @class file_operations 24 | !!---------------------------------------------------------------------- 25 | IMPLICIT NONE 26 | 27 | INTEGER(KIND=4) :: jk,jj,ji, jvar, jjvar ! dummy loop index 28 | INTEGER(KIND=4) :: ierr ! working integer 29 | INTEGER(KIND=4) :: narg, iargc, ijarg ! argument on line 30 | INTEGER(KIND=4) :: npiglo, npjglo ! size fo the domain 31 | INTEGER(KIND=4) :: iimin=1, iimax=0 ! i-limit of the domain 32 | INTEGER(KIND=4) :: ijmin=1, ijmax=0 ! j-limit of the domain 33 | INTEGER(KIND=4) :: ikmin=1, ikmax=0 ! k-limit of the domain 34 | INTEGER(KIND=4) :: nvars ! Number of variables in a file 35 | INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: ipk ! arrays of var id's 36 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: var1, var2 ! variables to compare 37 | REAL(KIND=4) :: dvar ! relative difference 38 | CHARACTER(LEN=256) :: cf1_in,cf2_in ! input file name 39 | CHARACTER(LEN=256) :: cv_in ! variable name 40 | CHARACTER(LEN=256) :: cldum ! working string 41 | CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: cv_names ! array of var name 42 | TYPE (variable), DIMENSION(:), ALLOCATABLE :: stypvar ! Type variable is defined in cdfio. 43 | 44 | !!-------------------------------------------------------------------------------------------------------------- 45 | CALL ReadCdfNames() 46 | 47 | narg = iargc() 48 | IF ( narg == 0 ) THEN 49 | PRINT *,' usage : cdfcmp -f1 IN-file1 -f2 IN-file2 -v IN-var ...' 50 | PRINT *,' ... [-lev kmin kmax ] [-zoom imin imax jmin jmax] ...' 51 | PRINT *,' ' 52 | PRINT *,' PURPOSE :' 53 | PRINT *,' Find where IN-var is different between IN-file1 and IN-file2 ' 54 | PRINT *,' Options allow to restrict the finding to a sub area in space' 55 | PRINT *,' ' 56 | PRINT *,' ARGUMENTS :' 57 | PRINT *,' -f1 IN-file1 : input file1' 58 | PRINT *,' -f2 IN-file2 : input file2' 59 | PRINT *,' -v IN-var : input variable' 60 | PRINT *,' ' 61 | PRINT *,' OPTIONS :' 62 | PRINT *,' [-lev kmin kmax ] : restrict to level between kmin and kmax. ' 63 | PRINT *,' [-zoom imin imax jmin jmax] : restrict to sub area specified' 64 | PRINT *,' by the given limits. ' 65 | PRINT *,' ' 66 | PRINT *,' REQUIRED FILES :' 67 | PRINT *,' none ' 68 | PRINT *,' ' 69 | PRINT *,' OUTPUT : ' 70 | PRINT *,' output is done on standard output.' 71 | STOP 72 | ENDIF 73 | !! 74 | ijarg = 1 75 | DO WHILE (ijarg <= narg) 76 | CALL getarg(ijarg,cldum) ; ijarg = ijarg + 1 77 | SELECT CASE ( cldum ) 78 | CASE ( '-f1' ) ; CALL getarg(ijarg, cf1_in) ; ijarg = ijarg + 1 79 | CASE ( '-f2' ) ; CALL getarg(ijarg, cf2_in) ; ijarg = ijarg + 1 80 | CASE ( '-v' ) ; CALL getarg(ijarg, cv_in ) ; ijarg = ijarg + 1 81 | CASE ( '-lev') ; CALL getarg(ijarg, cldum ) ; ijarg = ijarg + 1 ; READ(cldum,*) ikmin 82 | ; CALL getarg(ijarg, cldum ) ; ijarg = ijarg + 1 ; READ(cldum,*) ikmax 83 | CASE ('-zoom') ; CALL getarg(ijarg, cldum ) ; ijarg = ijarg + 1 ; READ(cldum,*) iimin 84 | ; CALL getarg(ijarg, cldum ) ; ijarg = ijarg + 1 ; READ(cldum,*) iimax 85 | ; CALL getarg(ijarg, cldum ) ; ijarg = ijarg + 1 ; READ(cldum,*) ijmin 86 | ; CALL getarg(ijarg, cldum ) ; ijarg = ijarg + 1 ; READ(cldum,*) ijmax 87 | CASE DEFAULT ; PRINT *,' ERROR : ', TRIM(cldum),' : unknown option.' ; STOP 99 88 | END SELECT 89 | END DO 90 | 91 | IF ( chkfile(cf1_in) .OR. chkfile(cf2_in) ) STOP 99 ! missing file 92 | IF ( chkvar(cf1_in, cv_in) .OR. chkvar(cf2_in, cv_in) ) STOP 99 ! missing var 93 | 94 | npiglo = getdim (cf1_in, cn_x) 95 | npjglo = getdim (cf1_in, cn_y) 96 | IF ( iimax == 0 ) iimax = npiglo 97 | IF ( ijmax == 0 ) ijmax = npjglo 98 | 99 | ! get the number of vertical levels of cv_in variable 100 | nvars = getnvar(cf1_in) 101 | ALLOCATE (ipk(nvars),cv_names(nvars),stypvar(nvars)) 102 | cv_names(:)=getvarname(cf1_in,nvars,stypvar) 103 | ipk(:) = getipk (cf1_in,nvars) 104 | DO jvar=1,nvars 105 | IF ( cv_names(jvar) == cv_in ) jjvar=jvar 106 | ENDDO 107 | IF ( ikmax == 0 ) ikmax = ipk(jjvar) 108 | 109 | ! Allocate memory. 110 | ALLOCATE(var1(npiglo, npjglo)) 111 | ALLOCATE(var2(npiglo, npjglo)) 112 | 113 | PRINT *,' Working with ', TRIM(cv_in),' defined on ', ipk(jjvar),' level(s)' 114 | DO jk = ikmin, ikmax 115 | PRINT *,'# -------------------------------------------' 116 | PRINT '(A19,I3)','# Checking level: ',jk 117 | PRINT *,'# i j k var1 var2 %reldiff' 118 | var1(:,:)=9999.0 119 | var2(:,:)=9999.0 120 | var1(:,:) = getvar(cf1_in, cv_in, jk, npiglo, npjglo) 121 | var2(:,:) = getvar(cf2_in, cv_in, jk, npiglo, npjglo) 122 | DO jj=ijmin, ijmax 123 | DO ji=iimin, iimax 124 | IF ( var1(ji,jj) /= var2(ji,jj) ) THEN 125 | dvar = 100.0*(var1(ji,jj)-var2(ji,jj))/var1(ji,jj) 126 | PRINT '(I4,2X,I4,2X,I3,2X,F8.3,2X,F8.3,2X,F8.3)',ji,jj,jk,var1(ji,jj),var2(ji,jj),dvar 127 | ENDIF 128 | ENDDO 129 | ENDDO 130 | ENDDO 131 | 132 | END PROGRAM cdfcmp 133 | -------------------------------------------------------------------------------- /src/cdfscale.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfscale 2 | !!====================================================================== 3 | !! *** PROGRAM cdfscale *** 4 | !!===================================================================== 5 | !! ** Purpose : Replace a variable in the file by its value x scale 6 | !! given in argument 7 | !! 8 | !! History : 3.0 : 12/2011 : J.M. Molines : Original code 9 | !! : 4.0 : 03/2017 : J.M. Molines 10 | !!---------------------------------------------------------------------- 11 | USE cdfio 12 | USE modcdfnames 13 | !!---------------------------------------------------------------------- 14 | !! CDFTOOLS_4.0 , MEOM 2017 15 | !! $Id$ 16 | !! Copyright (c) 2017, J.-M. Molines 17 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 18 | !! @class file_operations 19 | !!---------------------------------------------------------------------- 20 | IMPLICIT NONE 21 | 22 | INTEGER(KIND=4) :: jk, jvar, jt ! dummy loop index 23 | INTEGER(KIND=4) :: ivar ! index of working variable 24 | INTEGER(KIND=4) :: ierr, ireq ! working integer 25 | INTEGER(KIND=4) :: narg, iargc, ijarg ! browse line 26 | INTEGER(KIND=4) :: ncid ! ncid of input file for rewrite 27 | INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain 28 | INTEGER(KIND=4) :: npk, npt ! size of the domain 29 | INTEGER(KIND=4) :: nvars ! Number of variables in a file 30 | INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: ipk ! arrays of vertical level for each var 31 | INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: id_var ! arrays of var id 32 | 33 | REAL(KIND=4) :: vscale ! multiplicative scaling factor 34 | REAL(KIND=4) :: vdivide ! division factor 35 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: tab ! Arrays for data 36 | 37 | CHARACTER(LEN=256) :: cldum ! dummy string for getarg 38 | CHARACTER(LEN=256) :: cf_inout ! file name 39 | CHARACTER(LEN=256) :: cunits, clname, csname ! attributes 40 | CHARACTER(LEN=256) :: cv_inout ! variable name 41 | CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: cv_names ! array of var name 42 | 43 | TYPE(variable), DIMENSION(:), ALLOCATABLE :: stypvar ! type for attributes 44 | 45 | LOGICAL :: ll_scale = .true. 46 | 47 | !!---------------------------------------------------------------------- 48 | CALL ReadCdfNames() 49 | 50 | narg= iargc() 51 | IF ( narg == 0 ) THEN 52 | PRINT *,' usage : cdfscale -f INOUT-file -v IN-var -s SCAL-factor [-d DIVISION-factor]' 53 | PRINT *,' ' 54 | PRINT *,' PURPOSE :' 55 | PRINT *,' Replace IN-var in INOUT-file by its values x SCAL-factor or divided by' 56 | PRINT *,' DIVISION-factor if option -d is used instead of -s. ' 57 | PRINT *,' ' 58 | PRINT *,' CAUTION :' 59 | PRINT *,' #############################' 60 | PRINT *,' # INPUT FILE IS OVERWRITTEN #' 61 | PRINT *,' #############################' 62 | PRINT *,' ' 63 | PRINT *,' ARGUMENTS :' 64 | PRINT *,' -f INOUT-file : netcdf input file (!overwritten!).' 65 | PRINT *,' -v IN-var : netcdf variable to be scaled.' 66 | PRINT *,' -s SCAL-factor : Scale value to be used (multiplication factor).' 67 | PRINT *,' -d DIVISION-factor : Scale value to be used (division factor).' 68 | PRINT *,' ONLY one of -s or -d option must be used.' 69 | PRINT *,' ' 70 | PRINT *,' OUTPUT : ' 71 | PRINT *,' netcdf file : input file is rewritten ' 72 | PRINT *,' variables : same name as input.' 73 | STOP 74 | ENDIF 75 | 76 | ijarg=1 ; ireq=0 77 | DO WHILE ( ijarg <= narg ) 78 | CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 79 | SELECT CASE ( cldum ) 80 | CASE ( '-f' ) ; CALL getarg(ijarg, cf_inout ) ; ijarg=ijarg+1 ; ireq=ireq+1 81 | CASE ( '-v' ) ; CALL getarg(ijarg, cv_inout ) ; ijarg=ijarg+1 ; ireq=ireq+1 82 | CASE ( '-s' ) ; CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 ; ireq=ireq+1 ; READ(cldum,*) vscale 83 | CASE ( '-d' ) ; CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 ; ireq=ireq+1 ; READ(cldum,*) vdivide ; ll_scale=.false. 84 | CASE DEFAULT ; PRINT *,' ERROR :', TRIM(cldum),' : unknown option.' ; STOP 99 85 | END SELECT 86 | ENDDO 87 | ! 3 arguments are mandatory : here ijarg must be 4 88 | IF ( ireq /= 3 ) THEN ; PRINT *,' ERROR : need at least 3 arguments !' ; STOP 99 ; ENDIF 89 | 90 | IF ( chkfile (cf_inout) ) STOP 99 ! missing file 91 | 92 | npiglo = getdim (cf_inout, cn_x ) 93 | npjglo = getdim (cf_inout, cn_y ) 94 | npk = getdim (cf_inout, cn_z, kstatus=ierr) 95 | 96 | IF (ierr /= 0 ) THEN 97 | npk = getdim (cf_inout,'z',kstatus=ierr) 98 | IF (ierr /= 0 ) THEN 99 | PRINT *, 'ASSUME NO VERTICAL DIMENSIONS !' 100 | npk=0 101 | ENDIF 102 | ENDIF 103 | ncid = ncopen ( cf_inout ) 104 | npt = getdim ( cf_inout, cn_t ) 105 | 106 | PRINT *, 'npiglo=', npiglo 107 | PRINT *, 'npjglo=', npjglo 108 | PRINT *, 'npk =', npk 109 | PRINT *, 'npt =', npt 110 | 111 | ALLOCATE( tab(npiglo,npjglo) ) 112 | 113 | nvars = getnvar(cf_inout) 114 | 115 | ALLOCATE (cv_names(nvars), id_var(nvars),ipk(nvars), stypvar(nvars)) 116 | 117 | cv_names(:) = getvarname(cf_inout,nvars,stypvar) 118 | ipk(:) = getipk(cf_inout,nvars) 119 | id_var(:) = getvarid(cf_inout,nvars) 120 | 121 | ! look for cv_inout in the list of variables 122 | DO jvar = 1, nvars 123 | IF ( cv_inout == cv_names(jvar) ) ivar = jvar 124 | ENDDO 125 | 126 | PRINT *,' Working with ',TRIM(cv_inout),' variable number ', ivar 127 | PRINT *,' IPK : ', ipk(ivar) 128 | IF ( ll_scale ) THEN 129 | PRINT *,' scale : ', vscale 130 | ELSE 131 | PRINT *,' divide : ', vdivide 132 | ENDIF 133 | 134 | ! work only for ivar 135 | DO jt=1,npt 136 | PRINT *, ' JT = ', jt 137 | DO jk = 1, ipk(ivar) 138 | tab(:,:) = getvar(cf_inout, cv_names(ivar), jk, npiglo, npjglo, ktime=jt ) 139 | IF ( ll_scale ) THEN 140 | tab(:,:) = tab(:,:) * vscale 141 | ELSE 142 | tab(:,:) = tab(:,:) / vdivide 143 | ENDIF 144 | ierr = putvar(ncid, id_var(ivar), tab, jk, npiglo, npjglo, ktime=jt) 145 | ENDDO 146 | END DO 147 | 148 | ierr = closeout(ncid) 149 | 150 | END PROGRAM cdfscale 151 | -------------------------------------------------------------------------------- /src/cdffracinv.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdffracinv 2 | !!====================================================================== 3 | !! *** PROGRAM cdffracinv *** 4 | !!===================================================================== 5 | !! ** Purpose : Compute fraction of inventory for passive tracers 6 | !! output. This is the ratio between inventory at a 7 | !! grid point and total inventory 8 | !! 9 | !! History : 2.1 : 07/2010 : C.O. Dufour : Original code 10 | !! 3.0 : 01/2011 : J.M. Molines : Doctor norm + Lic. 11 | !! : 4.0 : 03/2017 : J.M. Molines 12 | !!---------------------------------------------------------------------- 13 | USE cdfio 14 | USE modcdfnames 15 | !!---------------------------------------------------------------------- 16 | !! CDFTOOLS_4.0 , MEOM 2017 17 | !! $Id$ 18 | !! Copyright (c) 2017, J.-M. Molines 19 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 20 | !! @class passive_tracer 21 | !!---------------------------------------------------------------------- 22 | IMPLICIT NONE 23 | 24 | INTEGER(KIND=4) :: jt ! dummy loop index 25 | INTEGER(KIND=4) :: narg, iargc, ijarg ! browse line 26 | INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain 27 | INTEGER(KIND=4) :: npk, npt ! size of the domain 28 | INTEGER(KIND=4) :: ncout ! ncid of output file 29 | INTEGER(KIND=4) :: ierr ! error status 30 | INTEGER(KIND=4), DIMENSION(1) :: ipk, id_varout ! level and varid's of output vars 31 | 32 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: trcinvij ! tracer inventory 33 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: fracinv ! fraction of inventory 34 | 35 | REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: dtim ! time counter 36 | 37 | CHARACTER(LEN=256) :: cf_trc ! tracer file (for inventory) 38 | CHARACTER(LEN=256) :: cf_out='fracinv.nc' ! output file name 39 | CHARACTER(LEN=256) :: cv_inv='invcfc' ! inventory name 40 | CHARACTER(LEN=256) :: cv_out='fracinv' ! output variable name 41 | CHARACTER(LEN=256) :: cglobal ! global attribute 42 | CHARACTER(LEN=256) :: cldum ! dummy string 43 | 44 | TYPE(variable), DIMENSION(1) :: stypvar ! structure for attributes 45 | 46 | LOGICAL :: lnc4 = .FALSE. ! Use nc4 with chunking and deflation 47 | !!---------------------------------------------------------------------- 48 | CALL ReadCdfNames() 49 | 50 | narg = iargc() 51 | IF ( narg == 0 ) THEN 52 | PRINT *,' usage : cdffracinv -trc TRC-file [-inv INV-name] [-o OUT-file] [-nc4]' 53 | PRINT *,' ' 54 | PRINT *,' PURPOSE :' 55 | PRINT *,' Compute the fraction of inventory for passive tracers, which is ' 56 | PRINT *,' the ratio between inventory at a grid point and the total inventory.' 57 | PRINT *,' ' 58 | PRINT *,' ARGUMENTS :' 59 | PRINT *,' -trc TRC-file : netcdf file with tracer inventory.' 60 | PRINT *,' ' 61 | PRINT *,' OPTIONS :' 62 | PRINT *,' [-inv INV-name ]: netcdf variable name for inventory [ ',TRIM(cv_inv),' ]' 63 | PRINT *,' [-o OUT-file ]: specify output file name instead of ', TRIM(cf_out) 64 | PRINT *,' [-nc4 ] : Use netcdf4 output with chunking and deflation level 1.' 65 | PRINT *,' This option is effective only if cdftools are compiled with' 66 | PRINT *,' a netcdf library supporting chunking and deflation.' 67 | PRINT *,' ' 68 | PRINT *,' REQUIRED FILES :' 69 | PRINT *,' none ' 70 | PRINT *,' ' 71 | PRINT *,' OUTPUT : ' 72 | PRINT *,' netcdf file : ', TRIM(cf_out) 73 | PRINT *,' variables : ', TRIM(cv_out) 74 | PRINT *,' ' 75 | STOP 76 | ENDIF 77 | 78 | ijarg = 1 79 | DO WHILE (ijarg <= narg ) 80 | CALL getarg(ijarg,cldum ) ; ijarg = ijarg + 1 81 | SELECT CASE ( cldum ) 82 | CASE ( '-trc' ) ; CALL getarg(ijarg, cf_trc) ; ijarg =ijarg + 1 83 | ! options 84 | CASE ( '-inv' ) ; CALL getarg(ijarg, cv_inv) ; ijarg =ijarg + 1 85 | CASE ( '-o' ) ; CALL getarg(ijarg, cf_out) ; ijarg =ijarg + 1 86 | CASE ( '-nc4' ) ; lnc4 = .TRUE. 87 | CASE DEFAULT ; PRINT *, ' ERROR : ', TRIM(cldum),' : unknown option.' ; STOP 99 88 | END SELECT 89 | END DO 90 | 91 | IF ( chkfile(cf_trc) ) STOP 99 ! missing file 92 | 93 | npiglo = getdim (cf_trc,cn_x) 94 | npjglo = getdim (cf_trc,cn_y) 95 | npk = getdim (cf_trc,cn_z) 96 | npt = getdim (cf_trc,cn_t) 97 | 98 | PRINT *, 'npiglo = ', npiglo 99 | PRINT *, 'npjglo = ', npjglo 100 | PRINT *, 'npk = ', npk 101 | 102 | ALLOCATE( trcinvij(npiglo,npjglo), fracinv(npiglo,npjglo) ) 103 | ALLOCATE( dtim(npt) ) 104 | 105 | WRITE(cglobal,9000) TRIM(cf_trc), TRIM(cv_inv) 106 | 9000 FORMAT('cdffracinv ',a,' -inv ',a ) 107 | 108 | CALL CreateOutput 109 | 110 | DO jt=1,npt 111 | fracinv( :,:) = 0. 112 | trcinvij(:,:) = getvar(cf_trc, cv_inv, 1, npiglo, npjglo, ktime=jt) 113 | ! JMM bug ?? : SUM(trcinij) is not the 'total inventory', should be weighted by model metrics ??? 114 | ! also assume spval is 0 115 | fracinv( :,:) = trcinvij(:,:) / SUM(trcinvij(:,:)) 116 | ierr = putvar(ncout, id_varout(1), fracinv, 1, npiglo, npjglo, ktime=jt) 117 | END DO 118 | 119 | ierr = closeout(ncout) 120 | 121 | CONTAINS 122 | 123 | SUBROUTINE CreateOutput 124 | !!--------------------------------------------------------------------- 125 | !! *** ROUTINE CreateOutput *** 126 | !! 127 | !! ** Purpose : Create netcdf output file(s) 128 | !! 129 | !! ** Method : Use stypvar global description of variables 130 | !! 131 | !!---------------------------------------------------------------------- 132 | ipk(1) = 1 133 | stypvar(1)%ichunk = (/npiglo,MAX(1,npjglo/30),1,1 /) 134 | stypvar(1)%cname = cv_out 135 | stypvar(1)%cunits = '' 136 | stypvar(1)%rmissing_value = 0. 137 | stypvar(1)%valid_min = 0. 138 | stypvar(1)%valid_max = 10000. 139 | stypvar(1)%clong_name = 'Fraction of inventory' 140 | stypvar(1)%cshort_name = cv_out 141 | stypvar(1)%conline_operation = 'N/A' 142 | stypvar(1)%caxis = 'TYX' 143 | 144 | ncout = create (cf_out, cf_trc, npiglo, npjglo, 1 , ld_nc4=lnc4 ) 145 | ierr = createvar (ncout, stypvar, 1, ipk, id_varout, cdglobal=cglobal, ld_nc4=lnc4 ) 146 | ierr = putheadervar(ncout, cf_trc, npiglo, npjglo, 1 ) 147 | 148 | dtim = getvar1d(cf_trc, cn_vtimec, npt ) 149 | ierr = putvar1d(ncout, dtim, npt, 'T') 150 | 151 | END SUBROUTINE CreateOutput 152 | 153 | END PROGRAM cdffracinv 154 | -------------------------------------------------------------------------------- /src/cdf_domain2bathy.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdf_domain2bathy 2 | !!====================================================================== 3 | !! *** PROGRAM cdf_domain2bathy *** 4 | !!===================================================================== 5 | !! ** Purpose : Create a bathy file from domain_cfg file 6 | !! 7 | !! ** Method : integrate e3t_0 on the wet points 8 | !! 9 | !! History : 4.0 : 10/2020 : J.M. Molines : 10 | !!---------------------------------------------------------------------- 11 | !!---------------------------------------------------------------------- 12 | !! routines : description 13 | !!---------------------------------------------------------------------- 14 | 15 | USE cdfio 16 | USE modcdfnames 17 | 18 | !!---------------------------------------------------------------------- 19 | !! CDFTOOLS_4.0 , MEOM 2020 20 | !! $Id$ 21 | !! Copyright (c) 2012, J.-M. Molines 22 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 23 | !! @class domain_file 24 | !!---------------------------------------------------------------------- 25 | IMPLICIT NONE 26 | 27 | INTEGER(KIND=4) :: jk, jt ! dummy loop index 28 | INTEGER(KIND=4) :: ierr, iko, it ! working integer 29 | INTEGER(KIND=4) :: narg, iargc, ijarg ! command line 30 | INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain 31 | INTEGER(KIND=4) :: npk, npt ! size of the domain 32 | INTEGER(KIND=4) :: ncout 33 | INTEGER(KIND=4), DIMENSION(1) :: ipk, id_varout ! only one output variable 34 | INTEGER(KIND=4), DIMENSION(:,:), ALLOCATABLE :: mbathy ! working input variable 35 | 36 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: e3t ! vertical metric 37 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: rlon, rlat ! output longitude, latitude 38 | 39 | REAL(KIND=8), DIMENSION(:,:), ALLOCATABLE :: dbati ! bathymetry 40 | REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: dtim ! time 41 | 42 | CHARACTER(LEN=256) :: cf_in, cf_out ! input/output file 43 | CHARACTER(LEN=256) :: cv_out ! output variable name 44 | CHARACTER(LEN=256) :: cldum ! working variables 45 | 46 | LOGICAL :: lnc4=.FALSE. ! nc4 flag 47 | LOGICAL :: lchk ! file flag 48 | TYPE(variable), DIMENSION(1) :: stypvar ! extension for attributes 49 | !!---------------------------------------------------------------------- 50 | CALL ReadCdfNames() 51 | 52 | narg= iargc() 53 | IF ( narg == 0 ) THEN 54 | PRINT *,' usage : cdf_domain2bathy -d DOMAINCFG-file [-nc4] [-o BATI-file]' 55 | PRINT *,' ' 56 | PRINT *,' PURPOSE :' 57 | PRINT *,' Compute the bathymetry of a configuration, consistent with the' 58 | PRINT *,' domain_cfg file given in argument. This program compute the bathymetry' 59 | PRINT *,' from the e3t_0 variable and bottom_level variable.' 60 | PRINT *,' ' 61 | PRINT *,' ARGUMENTS :' 62 | PRINT *,' -d DOMAINCFG-file: pass the name of the domain file to work with.' 63 | PRINT *,' ' 64 | PRINT *,' OPTIONS :' 65 | PRINT *,' [-nc4] : use netcdf4 output with chunking and deflation' 66 | PRINT *,' [-o BATI-file] : use specified output file instead of .nc' 67 | PRINT *,' ' 68 | PRINT *,' REQUIRED FILES :' 69 | PRINT *,' none' 70 | PRINT *,' ' 71 | PRINT *,' OUTPUT : ' 72 | PRINT *,' netcdf file : bati.nc of BATI-file if specified' 73 | PRINT *,' variables : bathy_meter' 74 | PRINT *,' ' 75 | STOP 76 | ENDIF 77 | 78 | ! browse command line 79 | ijarg = 1 80 | cf_out='none' 81 | DO WHILE ( ijarg <= narg ) 82 | CALL getarg (ijarg, cldum) ; ijarg = ijarg + 1 83 | SELECT CASE ( cldum) 84 | CASE ( '-d' ) ; CALL getarg (ijarg, cf_in ) ; ijarg = ijarg + 1 85 | ! options 86 | 87 | CASE ( '-nc4' ) ; lnc4 = .TRUE. 88 | CASE ( '-o' ) ; CALL getarg (ijarg, cf_out) ; ijarg = ijarg + 1 89 | CASE DEFAULT ; PRINT *,' ERROR : ', TRIM(cldum),' : unknown option.' ; STOP 99 90 | END SELECT 91 | END DO 92 | 93 | ! Security check 94 | lchk = chkfile ( cf_in ) 95 | IF ( lchk ) STOP 99 ! missing files 96 | 97 | IF ( cf_out == 'none' ) cf_out='bati.nc' 98 | 99 | npiglo = getdim (cf_in, cn_x ) 100 | npjglo = getdim (cf_in, cn_y ) 101 | npk = getdim (cf_in, 'z' ) 102 | npt = getdim (cf_in, 't' ) 103 | 104 | PRINT *, ' NPIGLO = ', npiglo 105 | PRINT *, ' NPJGLO = ', npjglo 106 | PRINT *, ' NPK = ', npk 107 | PRINT *, ' NPT = ', npt 108 | 109 | ! Allocate arrays 110 | ALLOCATE ( rlon(npiglo,npjglo), rlat(npiglo,npjglo) ) 111 | ALLOCATE ( mbathy(npiglo,npjglo) ) 112 | ALLOCATE ( dbati(npiglo,npjglo) ) 113 | ALLOCATE ( e3t(npiglo,npjglo) ) 114 | ALLOCATE ( dtim(npt) ) 115 | 116 | CALL CreateOutput 117 | 118 | mbathy(:,:) = getvar(cf_in,'bottom_level',1,npiglo, npjglo) 119 | dbati=0.d0 120 | 121 | DO jk = 1, npk 122 | e3t(:,:) = getvar(cf_in,'e3t_0',jk, npiglo,npjglo) 123 | WHERE( mbathy >= jk ) dbati(:,:)=dbati(:,:) + e3t(:,:) 124 | ENDDO 125 | ierr = putvar(ncout, id_varout(1) ,REAL(dbati), 1, npiglo, npjglo) 126 | ierr = closeout(ncout) 127 | 128 | CONTAINS 129 | 130 | SUBROUTINE CreateOutput 131 | !!--------------------------------------------------------------------- 132 | !! *** ROUTINE CreateOutput *** 133 | !! 134 | !! ** Purpose : Create netcdf output file(s) 135 | !! 136 | !! ** Method : Use stypvar global description of variables 137 | !! 138 | !!---------------------------------------------------------------------- 139 | ! prepare output variable 140 | ipk(:) = 1 141 | ! choose chunk size for output ... not easy not used if lnc4=.false. but 142 | ! anyway .. 143 | stypvar(1)%ichunk=(/npiglo,MAX(1,npjglo/30),1,1 /) 144 | cv_out = cn_bathymet 145 | 146 | stypvar(1)%cname = cv_out 147 | stypvar(1)%cunits = 'm' 148 | stypvar(1)%rmissing_value = 0. 149 | stypvar(1)%valid_min = 0. 150 | stypvar(1)%valid_max = 10000. 151 | stypvar(1)%clong_name = 'Bathymetry' 152 | stypvar(1)%cshort_name = cv_out 153 | stypvar(1)%conline_operation = 'N/A' 154 | stypvar(1)%caxis = 'TYX' 155 | 156 | rlon =getvar(cf_in, cn_glamt, 1, npiglo, npjglo) ! nav_lon 157 | rlat =getvar(cf_in, cn_gphit, 1, npiglo, npjglo) ! nav_lat 158 | 159 | ncout = create (cf_out, 'none', npiglo, npjglo, 0 , ld_nc4=lnc4) 160 | ierr = createvar (ncout, stypvar, 1, ipk, id_varout , ld_nc4=lnc4) 161 | ierr = putheadervar(ncout, cf_in, npiglo, npjglo, 0, pnavlon=rlon, pnavlat=rlat ) 162 | 163 | dtim = getvar1d (cf_in, cn_vtimec, npt ) 164 | ierr = putvar1d (ncout, dtim, npt, 'T') 165 | 166 | END SUBROUTINE CreateOutput 167 | 168 | END PROGRAM cdf_domain2bathy 169 | -------------------------------------------------------------------------------- /src/cdfdifmask.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfdifmask 2 | !!====================================================================== 3 | !! *** PROGRAM cdfdifmask *** 4 | !!===================================================================== 5 | !! ** Purpose : Build the difference between 2 mask files 6 | !! 7 | !! 8 | !! History : 2.1 : ?????? : ??? : Original code 9 | !! 3.0 : 12/2010 : J.M. Molines : Doctor norm + Lic. 10 | !! : 4.0 : 03/2017 : J.M. Molines 11 | !!---------------------------------------------------------------------- 12 | USE cdfio 13 | USE modcdfnames 14 | !!---------------------------------------------------------------------- 15 | !! CDFTOOLS_4.0 , MEOM 2017 16 | !! $Id$ 17 | !! Copyright (c) 2017, J.-M. Molines 18 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 19 | !! @class file_operations 20 | !!---------------------------------------------------------------------- 21 | IMPLICIT NONE 22 | 23 | INTEGER(KIND=4) :: jk, jvar ! dummy loop index 24 | INTEGER(KIND=4) :: ierr ! working integer 25 | INTEGER(KIND=4) :: narg, iargc, ijarg ! browsing command line 26 | INTEGER(KIND=4) :: npiglo, npjglo, npk ! size of the domain 27 | INTEGER(KIND=4) :: ncout ! ncid of output file 28 | INTEGER(KIND=4), DIMENSION(4) :: ipk ! outptut variables : levels, 29 | INTEGER(KIND=4), DIMENSION(4) :: id_varout ! ncdf varid's 30 | 31 | REAL(KIND=4), DIMENSION (:,:), ALLOCATABLE :: zmask, zmask2 ! 2D mask at current level 32 | 33 | REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: dtim ! dummy time variable 34 | 35 | CHARACTER(LEN=256) :: cf_out='mask_diff.nc' ! Output file name 36 | CHARACTER(LEN=256) :: cf_msk1, cf_msk2 ! name of input files 37 | CHARACTER(LEN=256) :: cv_in ! variable name 38 | CHARACTER(LEN=256) :: cldum ! working char variable 39 | 40 | TYPE(variable), DIMENSION(4) :: stypvar ! data structure 41 | 42 | LOGICAL :: lchk ! checking file existence 43 | LOGICAL :: lnc4 = .FALSE. ! Use nc4 with chunking and deflation 44 | !!---------------------------------------------------------------------- 45 | CALL ReadCdfNames() 46 | 47 | narg = iargc() 48 | IF ( narg == 0 ) THEN 49 | PRINT *,' usage : cdfdifmask -m mask1 mask2 [-o OUT-file] [-nc4]' 50 | PRINT *,' ' 51 | PRINT *,' PURPOSE :' 52 | PRINT *,' Compute the difference between 2 NEMO mask files.' 53 | PRINT *,' This difference is not easy to perform with nco.' 54 | PRINT *,' ' 55 | PRINT *,' ARGUMENTS :' 56 | PRINT *,' -m mask1 mask2 : model mask files to be compared.' 57 | PRINT *,' ' 58 | PRINT *,' OPTIONS :' 59 | PRINT *,' [-o OUT-file ]: specify output file name instead of ',TRIM(cf_out) 60 | PRINT *,' [-nc4 ] : Use netcdf4 output with chunking and deflation level 1.' 61 | PRINT *,' This option is effective only if cdftools are compiled with' 62 | PRINT *,' a netcdf library supporting chunking and deflation.' 63 | PRINT *,' ' 64 | PRINT *,' REQUIRED FILES :' 65 | PRINT *,' none' 66 | PRINT *,' ' 67 | PRINT *,' OUTPUT : ' 68 | PRINT *,' netcdf file : ', TRIM(cf_out) ,' unless -o option is used.' 69 | PRINT *,' variables : ',TRIM(cn_tmask),' ', TRIM(cn_umask),' ',TRIM(cn_vmask),' ',TRIM(cn_fmask) 70 | STOP 71 | ENDIF 72 | 73 | ijarg=1 74 | DO WHILE ( ijarg <= narg ) 75 | CALL getarg(ijarg, cldum) ; ijarg=ijarg+1 76 | SELECT CASE ( cldum ) 77 | CASE ( '-m' ) ; CALL getarg(ijarg, cf_msk1) ; ijarg=ijarg+1 78 | ; CALL getarg(ijarg, cf_msk2) ; ijarg=ijarg+1 79 | ! options 80 | CASE ( '-o' ) ; CALL getarg(ijarg, cf_out ) ; ijarg=ijarg+1 81 | CASE ( '-nc4' ) ; lnc4 = .TRUE. 82 | CASE DEFAULT ; PRINT *,' ERROR : ', TRIM(cldum),' : unknown option.' ; STOP 99 83 | END SELECT 84 | END DO 85 | 86 | lchk = chkfile ( cf_msk1 ) 87 | lchk = lchk .OR. chkfile ( cf_msk2 ) 88 | IF ( lchk ) STOP 99 ! missing file 89 | 90 | npiglo = getdim (cf_msk1, cn_x) 91 | npjglo = getdim (cf_msk1, cn_y) 92 | npk = getdim (cf_msk1, 'z' , kstatus=ierr ) ! mask file have a z depth dim instead of depth ... 93 | IF (ierr /= 0 ) THEN 94 | npk = getdim (cf_msk1, 'nav_lev' , kstatus=ierr ) ! mask file have a z depth dim instead of depth ... 95 | IF (ierr /= 0 ) THEN 96 | npk = getdim (cf_msk1, 'deptht' , kstatus=ierr ) ! mask file have a z depth dim instead of depth ... 97 | ENDIF 98 | ENDIF 99 | IF (ierr /= 0 ) THEN 100 | PRINT *,' E R R O R : Vertical dimension name unknown' ; STOP 99 101 | ENDIF 102 | 103 | ALLOCATE (zmask(npiglo,npjglo), zmask2(npiglo,npjglo)) 104 | ALLOCATE ( dtim(1) ) 105 | 106 | CALL CreateOutput 107 | 108 | DO jvar=1,4 109 | cv_in = stypvar(jvar)%cname 110 | PRINT *, ' making difference for ', TRIM(cv_in) 111 | DO jk=1, npk 112 | PRINT * ,'jk = ', jk 113 | zmask(:,:) = getvar(cf_msk1, cv_in, jk, npiglo, npjglo) 114 | zmask2(:,:) = getvar(cf_msk2, cv_in, jk, npiglo, npjglo) 115 | zmask(:,:) = zmask2(:,:) - zmask(:,:) 116 | ierr = putvar(ncout, id_varout(jvar), zmask, jk, npiglo, npjglo) 117 | END DO ! loop to next level 118 | END DO 119 | 120 | ierr = closeout(ncout) 121 | 122 | CONTAINS 123 | 124 | SUBROUTINE CreateOutput 125 | !!--------------------------------------------------------------------- 126 | !! *** ROUTINE CreateOutput *** 127 | !! 128 | !! ** Purpose : Create netcdf output file(s) 129 | !! 130 | !! ** Method : Use stypvar global description of variables 131 | !! 132 | !!---------------------------------------------------------------------- 133 | DO jvar = 1, 4 134 | stypvar(jvar)%ichunk = (/npiglo,MAX(1,npjglo/30),1,1 /) 135 | ENDDO 136 | ipk(:) = npk 137 | stypvar(:)%cunits = '1/0' 138 | stypvar(:)%rmissing_value = 9999. 139 | stypvar(:)%valid_min = 0. 140 | stypvar(:)%valid_max = 1. 141 | stypvar(:)%conline_operation = 'N/A' 142 | stypvar(:)%caxis = 'TZYX' 143 | stypvar(:)%cprecision = 'by' 144 | 145 | stypvar(1)%cname=cn_tmask ; stypvar(1)%clong_name=cn_tmask ; stypvar(1)%cshort_name=cn_tmask 146 | stypvar(2)%cname=cn_umask ; stypvar(2)%clong_name=cn_umask ; stypvar(2)%cshort_name=cn_umask 147 | stypvar(3)%cname=cn_vmask ; stypvar(3)%clong_name=cn_vmask ; stypvar(3)%cshort_name=cn_vmask 148 | stypvar(4)%cname=cn_fmask ; stypvar(4)%clong_name=cn_fmask ; stypvar(4)%cshort_name=cn_fmask 149 | 150 | ncout = create (cf_out, cf_msk1, npiglo, npjglo, npk, cdep='z', cdepvar='nav_lev', ld_nc4=lnc4 ) 151 | ierr = createvar (ncout, stypvar, 4, ipk, id_varout , ld_nc4=lnc4 ) 152 | ierr = putheadervar(ncout, cf_msk1, npiglo, npjglo, npk, cdep='nav_lev' ) 153 | 154 | dtim(:) = 0.d0 155 | ierr = putvar1d(ncout, dtim, 1, 'T') 156 | 157 | END SUBROUTINE CreateOutput 158 | 159 | END PROGRAM cdfdifmask 160 | -------------------------------------------------------------------------------- /src/cdfpendep.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfpendep 2 | !!====================================================================== 3 | !! *** PROGRAM cdfpendep *** 4 | !!===================================================================== 5 | !! ** Purpose : Compute penetration depth for passive tracer output. 6 | !! This is the ratio between inventory and surface 7 | !! concentration. 8 | !! 9 | !! ** Method : takes TRC files as input 10 | !! 11 | !! History : 2.1 : 02/2008 : J.M. Molines : Original code 12 | !! : 2.1 : 09/2010 : C. Dufour : Adapation to TOP evolution 13 | !! 3.0 : 01/2011 : J.M. Molines : Doctor norm + Lic. 14 | !! : 4.0 : 03/2017 : J.M. Molines 15 | !!---------------------------------------------------------------------- 16 | USE cdfio 17 | USE modcdfnames 18 | !!---------------------------------------------------------------------- 19 | !! CDFTOOLS_4.0 , MEOM 2017 20 | !! $Id$ 21 | !! Copyright (c) 2017, J.-M. Molines 22 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 23 | !! @class passive_tracer 24 | !!---------------------------------------------------------------------- 25 | IMPLICIT NONE 26 | 27 | INTEGER(KIND=4) :: jt ! dummy loop index 28 | INTEGER(KIND=4) :: narg, iargc, ijarg ! browse command line 29 | INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain 30 | INTEGER(KIND=4) :: npk, npt ! size of the domain 31 | INTEGER(KIND=4) :: ncout ! ncid of output file 32 | INTEGER(KIND=4) :: ierr ! error status 33 | INTEGER(KIND=4), DIMENSION(1) :: ipk, id_varout ! levels and varid's of output vats 34 | 35 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: trcinv, trcsurf ! inventory, surface concentration 36 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: rpendep ! penetration depth 37 | 38 | REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: dtim ! time counter 39 | 40 | CHARACTER(LEN=256) :: cf_trcfil ! tracer file name 41 | CHARACTER(LEN=256) :: cf_inv ! inventory file name 42 | CHARACTER(LEN=256) :: cf_out='pendep.nc' ! output file 43 | CHARACTER(LEN=256) :: cv_inv ! inventory variable name 44 | CHARACTER(LEN=256) :: cv_trc ! tracer variable name 45 | CHARACTER(LEN=256) :: cglobal ! global attribute 46 | CHARACTER(LEN=256) :: cldum ! dummy string 47 | 48 | TYPE(variable), DIMENSION(1) :: stypvar ! structure for attributes 49 | 50 | LOGICAL :: lnc4 = .FALSE. ! Use nc4 with chunking and deflation 51 | !!---------------------------------------------------------------------- 52 | CALL ReadCdfNames() 53 | 54 | cv_inv = cn_invcfc 55 | cv_trc = cn_cfc11 56 | narg = iargc() 57 | IF ( narg == 0 ) THEN 58 | PRINT *,' usage : cdfpendep -trc TRC-file -i INV-file [-o OUT-file] [-nc4] ...' 59 | PRINT *,' ... [-vinv inventory_name -vtrc trc_name ]' 60 | PRINT *,' ' 61 | PRINT *,' PURPOSE :' 62 | PRINT *,' Compute the penetration depth for passive tracers. It is the ratio' 63 | PRINT *,' between the inventory and the surface concentration of the tracer.' 64 | PRINT *,' ' 65 | PRINT *,' ARGUMENTS :' 66 | PRINT *,' -trc TRC-file : netcdf file with tracer concentration.' 67 | PRINT *,' -i INV-file : netcdf file with inventory of the tracer.' 68 | PRINT *,' ' 69 | PRINT *,' OPTIONS :' 70 | PRINT *,' [-vinv inventory_name ] : specify netcdf variable name for inventory.' 71 | PRINT *,' Default is ', TRIM(cv_inv) 72 | PRINT *,' [-vtrc trc_name ] : specify netcdf variable name for tracer.' 73 | PRINT *,' Default is ', TRIM(cv_trc) 74 | PRINT *,' [-o OUT-file ] : specify output file name instead of ', TRIM(cf_out) 75 | PRINT *,' [ -nc4 ] : Use netcdf4 output with chunking and deflation level 1.' 76 | PRINT *,' This option is effective only if cdftools are compiled with' 77 | PRINT *,' a netcdf library supporting chunking and deflation.' 78 | PRINT *,' ' 79 | PRINT *,' REQUIRED FILES :' 80 | PRINT *,' none' 81 | PRINT *,' ' 82 | PRINT *,' OUTPUT : ' 83 | PRINT *,' netcdf file : ', TRIM(cf_out) 84 | PRINT *,' variables : pendep (m)' 85 | PRINT *,' ' 86 | STOP 87 | ENDIF 88 | 89 | ijarg = 1 90 | DO WHILE ( ijarg <= narg) 91 | CALL getarg(ijarg, cldum ) ; ijarg = ijarg + 1 92 | SELECT CASE ( cldum ) 93 | CASE ('-trc' ) ; CALL getarg(ijarg, cf_trcfil) ; ijarg=ijarg+1 94 | CASE ('-i' ) ; CALL getarg(ijarg, cf_inv ) ; ijarg=ijarg+1 95 | ! options 96 | CASE ('-o' ) ; CALL getarg(ijarg, cf_out ) ; ijarg=ijarg+1 97 | CASE ('-vinv') ; CALL getarg(ijarg, cv_inv ) ; ijarg=ijarg+1 98 | CASE ('-vtrc') ; CALL getarg(ijarg, cv_trc ) ; ijarg=ijarg+1 99 | CASE ('-nc4' ) ; lnc4 = .TRUE. 100 | CASE DEFAULT ; PRINT *, ' ERROR : ', TRIM(cldum),' : unknown option.' ; STOP 99 101 | END SELECT 102 | END DO 103 | 104 | IF ( chkfile(cf_trcfil) .OR. chkfile(cf_inv) ) STOP 99 ! missing file 105 | 106 | npiglo = getdim (cf_trcfil,cn_x) 107 | npjglo = getdim (cf_trcfil,cn_y) 108 | npk = getdim (cf_trcfil,cn_z) 109 | npt = getdim (cf_trcfil,cn_t) 110 | 111 | PRINT *, 'npiglo = ', npiglo 112 | PRINT *, 'npjglo = ', npjglo 113 | PRINT *, 'npk = ', npk 114 | PRINT *, 'npt = ', npt 115 | 116 | ALLOCATE( trcinv(npiglo,npjglo), trcsurf(npiglo,npjglo), rpendep(npiglo,npjglo) ) 117 | ALLOCATE( dtim(npt) ) 118 | 119 | WRITE(cglobal,9000) TRIM(cf_trcfil), TRIM(cf_inv), TRIM(cv_inv), TRIM(cv_trc) 120 | 9000 FORMAT('cdfpendep ',a,' ',a,' -inv ',a,' -trc ',a ) 121 | 122 | CALL CreateOutput 123 | 124 | DO jt = 1,npt 125 | rpendep(:,:) = 0. 126 | trcinv( :,:) = getvar(cf_inv, cv_inv, 1, npiglo, npjglo, ktime=jt) 127 | trcsurf(:,:) = getvar(cf_trcfil, cv_trc, 1, npiglo, npjglo, ktime=jt) 128 | 129 | WHERE( trcsurf /= 0 ) rpendep = trcinv/trcsurf 130 | ierr=putvar(ncout, id_varout(1), rpendep, 1, npiglo, npjglo, ktime=jt) 131 | END DO 132 | 133 | ierr = closeout(ncout) 134 | 135 | CONTAINS 136 | 137 | SUBROUTINE CreateOutput 138 | !!--------------------------------------------------------------------- 139 | !! *** ROUTINE CreateOutput *** 140 | !! 141 | !! ** Purpose : Create netcdf output file(s) 142 | !! 143 | !! ** Method : Use stypvar global description of variables 144 | !! 145 | !!---------------------------------------------------------------------- 146 | ipk(1) = 1 147 | stypvar(1)%ichunk = (/npiglo,MAX(1,npjglo/30),1,1 /) 148 | stypvar(1)%cname = cn_pendep 149 | stypvar(1)%cunits = 'm' 150 | stypvar(1)%rmissing_value = 0. 151 | stypvar(1)%valid_min = 0. 152 | stypvar(1)%valid_max = 10000. 153 | stypvar(1)%clong_name = 'Penetration depth' 154 | stypvar(1)%cshort_name = cn_pendep 155 | stypvar(1)%conline_operation = 'N/A' 156 | stypvar(1)%caxis = 'TYX' 157 | 158 | ncout = create (cf_out, cf_trcfil, npiglo, npjglo, 1 , ld_nc4=lnc4 ) 159 | ierr = createvar (ncout, stypvar, 1, ipk, id_varout, cdglobal=cglobal, ld_nc4=lnc4 ) 160 | ierr = putheadervar(ncout, cf_trcfil, npiglo, npjglo, 1 ) 161 | 162 | dtim = getvar1d(cf_trcfil, cn_vtimec, npt ) 163 | ierr = putvar1d(ncout, dtim, npt, 'T') 164 | 165 | END SUBROUTINE CreateOutput 166 | 167 | END PROGRAM cdfpendep 168 | -------------------------------------------------------------------------------- /src/cdffixanom.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdffixanom 2 | !!====================================================================== 3 | !! *** PROGRAM cdffixanom *** 4 | !!===================================================================== 5 | !! ** Purpose : Tool dedicated to the local correction of initial 6 | !! conditions files, where deepest part are some time 7 | !! Spurious. Below a given level, the values of the variable 8 | !! are replaced by the upper level. 9 | !! 10 | !! History : 4.0 : 04/2020 : J.M. Molines (from cdfmax/cdfmltmask) 11 | !!---------------------------------------------------------------------- 12 | USE cdfio 13 | USE modcdfnames 14 | !!---------------------------------------------------------------------- 15 | !! CDFTOOLS_4.0 , MEOM 2020 16 | !! $Id$ 17 | !! Copyright (c) 2020, J.-M. Molines 18 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 19 | !! @class file_informations 20 | !!---------------------------------------------------------------------- 21 | IMPLICIT NONE 22 | 23 | INTEGER(KIND=4) :: jk, jt 24 | INTEGER(KIND=4) :: narg, iargc, ijarg 25 | INTEGER(KIND=4) :: ni, nj, nk, nt ! size of the global domain 26 | INTEGER(KIND=4) :: niz, njz ! size of the domain 27 | INTEGER(KIND=4) :: ikref ! revel of reference 28 | INTEGER(KIND=4) :: iimin=1, iimax=0 ! i-limit of the domain 29 | INTEGER(KIND=4) :: ijmin=1, ijmax=0 ! j-limit of the domain 30 | INTEGER(KIND=4) :: itmin=1, itmax=0 ! t-limit of the domain 31 | INTEGER(KIND=4) :: istatus,ierr ! working integer 32 | 33 | REAL(KIND=4) :: zspval ! missing value or spval 34 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: v2d, vref ! running 2d var, and reference var. 35 | 36 | CHARACTER(LEN=256) :: cf_in ! input file name 37 | CHARACTER(LEN=256) :: cf_out ! input file name 38 | CHARACTER(LEN=256) :: cv_in='none' ! current variable name 39 | CHARACTER(LEN=256) :: cldum ! dummy char variable 40 | 41 | LOGICAL :: lout = .FALSE. ! Flag set when name of output file given 42 | 43 | !!---------------------------------------------------------------------- 44 | CALL ReadCdfNames() 45 | 46 | narg = iargc() 47 | IF ( narg == 0 ) THEN 48 | PRINT *,' usage : cdffixanom -f IN-file -v IN-var -reflev kref ...' 49 | PRINT *,' ... [-w imin imax jmin jmax] [-time tmin tmax ] ...' 50 | PRINT *,' ... [-o OUT-file ]' 51 | PRINT *,' ' 52 | PRINT *,' PURPOSE :' 53 | PRINT *,' In the subdomain, replace the variable value by values at kref,' 54 | PRINT *,' from kref+1 to the last wet point. Action is performed on a copy' 55 | PRINT *,' of the input file.' 56 | PRINT *,' ' 57 | PRINT *,' ARGUMENTS :' 58 | PRINT *,' -f IN-file : input file ' 59 | PRINT *,' -v IN-var : input variable' 60 | PRINT *,' -reflev kref : Give reference level' 61 | PRINT *,' ' 62 | PRINT *,' OPTIONS :' 63 | PRINT *,' [-w imin imax jmin jmax] : restrict to sub area specified by the ' 64 | PRINT *,' given limits. ' 65 | PRINT *,' [-time tmin tmax ] : restrict to the indicated time windows.' 66 | PRINT *,' [-o OUT-file] : specify the output file name instead of default.' 67 | PRINT *,' ' 68 | PRINT *,' REQUIRED FILES :' 69 | PRINT *,' none' 70 | PRINT *,' ' 71 | PRINT *,' OUTPUT : ' 72 | PRINT *,' output is done on _fixanom, or OUT-file if -o option used.' 73 | STOP 74 | ENDIF 75 | 76 | ijarg=1 77 | ikref=0 78 | cv_in = 'none' 79 | DO WHILE (ijarg <= narg) 80 | CALL getarg(ijarg, cldum) ; ijarg = ijarg + 1 81 | SELECT CASE (cldum ) 82 | CASE ( '-f' ) ; CALL getarg(ijarg, cf_in) ; ijarg = ijarg + 1 83 | CASE ( '-v' ) ; CALL getarg(ijarg, cv_in) ; ijarg = ijarg + 1 84 | CASE ( '-reflev' ) ; CALL getarg(ijarg, cldum) ; ijarg = ijarg + 1 ; READ(cldum,*) ikref 85 | CASE ( '-w' ) ; CALL getarg(ijarg, cldum) ; ijarg = ijarg + 1 ; READ(cldum,*) iimin 86 | ; CALL getarg(ijarg, cldum) ; ijarg = ijarg + 1 ; READ(cldum,*) iimax 87 | ; CALL getarg(ijarg, cldum) ; ijarg = ijarg + 1 ; READ(cldum,*) ijmin 88 | ; CALL getarg(ijarg, cldum) ; ijarg = ijarg + 1 ; READ(cldum,*) ijmax 89 | CASE ( '-time' ) ; CALL getarg(ijarg, cldum) ; ijarg = ijarg + 1 ; READ(cldum,*) itmin 90 | ; CALL getarg(ijarg, cldum) ; ijarg = ijarg + 1 ; READ(cldum,*) itmax 91 | CASE ( '-o' ) ; CALL getarg(ijarg, cf_out); ijarg = ijarg + 1 ; lout=.TRUE. 92 | 93 | CASE DEFAULT ; PRINT *, ' ERROR : ', TRIM(cldum),' : unknown option.' ; STOP 99 94 | END SELECT 95 | END DO 96 | 97 | ! Check if reference level given 98 | IF ( ikref == 0 ) THEN 99 | PRINT *,' *** ERROR : You must specify a reference level with -reflev ' 100 | STOP 99 101 | ENDIF 102 | 103 | ! Check for variable name 104 | IF ( TRIM(cv_in) == 'none' ) THEN 105 | PRINT *,' *** ERROR : You must specify a variable name with -v option.' 106 | STOP 99 107 | ENDIF 108 | 109 | ! Check for missing files 110 | IF ( chkfile(cf_in) ) STOP 99 ! missing file 111 | 112 | IF ( .NOT. lout ) THEN 113 | cf_out = TRIM(cf_in)//'_fixanom' 114 | ENDIF 115 | CALL system(' dd bs=10000000 if='//TRIM(cf_in)//' of='//TRIM(cf_out) ) 116 | cf_in = cf_out 117 | 118 | PRINT *,' Working on copy : ', TRIM(cf_out) 119 | 120 | ni=0 ; nj=0; nk=0; nt=0 121 | 122 | ni = getdim(cf_in, cn_x, cldum, istatus) 123 | IF ( istatus == 1 ) THEN 124 | ni = getdim(cf_in, 'lon', cldum, istatus) 125 | IF ( istatus == 1 ) THEN 126 | PRINT *,' No X or lon dim found ' ; STOP 99 127 | ENDIF 128 | ENDIF 129 | IF ( iimax == 0 ) iimax = ni 130 | 131 | nj = getdim(cf_in, cn_y, cldum, istatus) 132 | IF ( istatus == 1 ) THEN 133 | nj = getdim(cf_in, 'lat', cldum, istatus) 134 | IF ( istatus == 1 ) THEN 135 | PRINT *,' No y or lat dim found ' ; STOP 99 136 | ENDIF 137 | ENDIF 138 | IF ( ijmax == 0 ) ijmax = nj 139 | 140 | nk=getdim(cf_in, cn_z, cldum, istatus) 141 | IF ( istatus == 1 ) THEN 142 | nk = getdim(cf_in, 'z', cldum, istatus) 143 | IF ( istatus == 1 ) THEN 144 | nk = getdim(cf_in, 'lev', cldum, istatus) 145 | IF ( istatus == 1 ) THEN 146 | PRINT *,' No dep or z or lev dim found ' 147 | nk = 1 148 | ENDIF 149 | ENDIF 150 | ENDIF 151 | IF ( nk <= ikref ) THEN 152 | PRINT *,' *** ERROR : reference level >= total levels in files' 153 | STOP 99 154 | ENDIF 155 | 156 | nt = getdim(cf_in, cn_t, cldum, istatus) 157 | 158 | IF ( istatus == 1 ) THEN 159 | nt = getdim(cf_in, 'step', cldum, istatus) 160 | IF ( istatus == 1 ) THEN 161 | PRINT *,' No time or step dim found ' 162 | ENDIF 163 | ENDIF 164 | 165 | ! fix the size of the zoomed area, or the whole domain if no zoom 166 | niz = iimax - iimin + 1 167 | njz = ijmax - ijmin + 1 168 | 169 | IF (nt == 0 ) nt = 1 ! assume a 1 time frame file 170 | IF ( itmax == 0 ) itmax = nt 171 | 172 | zspval = getatt(cf_in, cv_in, cn_missing_value) 173 | 174 | ALLOCATE (vref(niz,njz), v2d(niz,njz) ) 175 | 176 | ! Loop on time 177 | DO jt=itmin, itmax 178 | ! read ref value 179 | vref(:,:) = getvar(cf_in, cv_in, ikref, niz, njz, kimin=iimin, kjmin=ijmin, ktime=jt) 180 | ! Loop on level 181 | DO jk=ikref+1, nk 182 | v2d(:,:) = getvar(cf_in, cv_in, jk, niz, njz, kimin=iimin, kjmin=ijmin, ktime=jt) 183 | WHERE (v2d /= zspval ) v2d=vref 184 | ierr = putvar(cf_out, cv_in, jk, niz, njz, kimin=iimin, kjmin=ijmin, ptab=v2d,ktime=jt) 185 | ENDDO 186 | ENDDO 187 | 188 | END PROGRAM cdffixanom 189 | -------------------------------------------------------------------------------- /src/cdfrmsssh.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfrmsssh 2 | !!====================================================================== 3 | !! *** PROGRAM cdfrmsssh *** 4 | !!===================================================================== 5 | !! ** Purpose : Compute the RMS of SSH, from the mean squared value. 6 | !! 7 | !! ** Method : Read gridT and gridT2 and compute rms 8 | !! 9 | !! History : 2.1 : 11/2004 : J.M. Molines : Original code 10 | !! 3.0 : 05/2011 : J.M. Molines : Doctor norm + Lic. 11 | !! : 4.0 : 03/2017 : J.M. Molines 12 | !!---------------------------------------------------------------------- 13 | USE cdfio 14 | USE modcdfnames 15 | !!---------------------------------------------------------------------- 16 | !! CDFTOOLS_4.0 , MEOM 2017 17 | !! $Id$ 18 | !! Copyright (c) 2017, J.-M. Molines 19 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 20 | !! @class statistics 21 | !!---------------------------------------------------------------------- 22 | IMPLICIT NONE 23 | 24 | INTEGER(KIND=4) :: jk, jt ! dummy loop index 25 | INTEGER(KIND=4) :: narg, iargc ! command line 26 | INTEGER(KIND=4) :: ijarg, ixtra ! command line 27 | INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain 28 | INTEGER(KIND=4) :: npk, npt ! size of the domain 29 | INTEGER(KIND=4) :: ncout ! ncid of output variable 30 | INTEGER(KIND=4) :: ierr ! error status 31 | INTEGER(KIND=4), DIMENSION(1) :: ipko, id_varout ! output variable 32 | 33 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: zvbar, zvba2 ! mean and mean2 variable 34 | 35 | REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: dtim ! time counter 36 | REAL(KIND=8), DIMENSION(:,:), ALLOCATABLE :: dsdev ! standard deviation 37 | 38 | CHARACTER(LEN=256) :: cf_in ! input mean file name 39 | CHARACTER(LEN=256) :: cf_in2 ! input mean2 file name 40 | CHARACTER(LEN=256) :: cf_out = 'rms.nc' ! output file name 41 | CHARACTER(LEN=256) :: cv_in, cv_in2 ! input variable names 42 | CHARACTER(LEN=256) :: cldum ! dummy character variable 43 | CHARACTER(LEN=256) :: cl_sossheig ! local name for ssh 44 | CHARACTER(LEN=256) :: cl_sossheig2 ! local name for ssh2 45 | 46 | TYPE(variable), DIMENSION(1) :: stypvaro ! output data structure 47 | 48 | LOGICAL :: lchk = .FALSE. ! flag for missing files 49 | LOGICAL :: lnc4 = .FALSE. ! flag for missing files 50 | !!---------------------------------------------------------------------- 51 | CALL ReadCdfNames() 52 | 53 | narg= iargc() 54 | IF ( narg == 0 ) THEN 55 | PRINT *,' usage : cdfrmsssh -t T-file -t2 T2-file [-o OUT-file] [-nc4] ... ' 56 | PRINT *,' ... [-var VAR-ssh VAR-ssh2]' 57 | PRINT *,' ' 58 | PRINT *,' PURPOSE :' 59 | PRINT *,' Compute the standard deviation of the SSH from its mean value' 60 | PRINT *,' its mean square value. ' 61 | PRINT *,' ' 62 | PRINT *,' Note that what is computed in this program is stictly the' 63 | PRINT *,' standard deviation. It is very often called RMS, which is' 64 | PRINT *,' an abuse. It is the same only in the case of zero mean value.' 65 | PRINT *,' However, for historical reason, the name of this tool, remains' 66 | PRINT *,' unchanged: cdfrmsssh' 67 | PRINT *,' ' 68 | PRINT *,' ARGUMENTS :' 69 | PRINT *,' -t T-file : netcdf file with mean values for SSH' 70 | PRINT *,' -t2 T2-file : netcdf file with mean squared values for SSH' 71 | PRINT *,' ' 72 | PRINT *,' OPTIONS :' 73 | PRINT *,' [-o OUT-file] : specify the name of the output file instead' 74 | PRINT *,' of default name ', TRIM(cf_out) 75 | PRINT *,' [-nc4] : use netcdf4 with chunking and deflation ' 76 | PRINT *,' [-var VAR-ssh VAR-ssh2] : specify the variable name for mean and ' 77 | PRINT *,' mean-squared ssh, if they differ from the standard names.' 78 | PRINT *,' ' 79 | PRINT *,' REQUIRED FILES :' 80 | PRINT *,' none' 81 | PRINT *,' ' 82 | PRINT *,' OUTPUT : ' 83 | PRINT *,' netcdf file : ', TRIM(cf_out) ,' unless option -o is used.' 84 | PRINT *,' variables : ', TRIM(cn_sossheig)//'_rms, same unit than the input.' 85 | PRINT *,' ' 86 | PRINT *,' SEA ALSO :' 87 | PRINT *,' cdfstd, cdfstdevw, cdfstdevts.' 88 | STOP 89 | ENDIF 90 | 91 | cl_sossheig = cn_sossheig 92 | cl_sossheig2 = TRIM(cn_sossheig)//'_sqd' 93 | 94 | ijarg = 1 95 | DO WHILE ( ijarg <= narg) 96 | CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 97 | SELECT CASE ( cldum ) 98 | CASE ( '-t' ) ; CALL getarg(ijarg, cf_in ) ; ijarg=ijarg+1 99 | CASE ( '-t2' ) ; CALL getarg(ijarg, cf_in2 ) ; ijarg=ijarg+1 100 | ! options 101 | CASE ( '-nc4' ) ; lnc4 = .TRUE. 102 | CASE ( '-o' ) ; CALL getarg(ijarg, cf_out ) ; ijarg=ijarg+1 103 | CASE ( '-var' ) ; CALL getarg(ijarg, cl_sossheig ) ; ijarg=ijarg+1 104 | ; ; CALL getarg(ijarg, cl_sossheig2 ) ; ijarg=ijarg+1 105 | CASE DEFAULT ; PRINT *,' ERROR : ', TRIM(cldum),' : unknown option.' ; STOP 99 106 | END SELECT 107 | ENDDO 108 | 109 | cv_in = cl_sossheig 110 | cv_in2 = cl_sossheig2 111 | 112 | ! check existence of files 113 | lchk = lchk .OR. chkfile(cf_in ) 114 | lchk = lchk .OR. chkfile(cf_in2 ) 115 | IF (lchk ) STOP 99 ! missing file 116 | 117 | npiglo = getdim (cf_in, cn_x) 118 | npjglo = getdim (cf_in, cn_y) 119 | npk = getdim (cf_in, cn_z) 120 | npt = getdim (cf_in, cn_t) 121 | 122 | PRINT *, 'npiglo = ', npiglo 123 | PRINT *, 'npjglo = ', npjglo 124 | PRINT *, 'npk = ', npk 125 | PRINT *, 'npt = ', npt 126 | 127 | ALLOCATE( zvbar(npiglo,npjglo), zvba2(npiglo,npjglo) ) 128 | ALLOCATE( dsdev(npiglo,npjglo), dtim(npt) ) 129 | 130 | CALL CreateOutput 131 | 132 | DO jt = 1, npt 133 | zvbar(:,:) = getvar(cf_in, cv_in, 1, npiglo, npjglo, ktime=jt) 134 | zvba2(:,:) = getvar(cf_in2, cv_in2, 1, npiglo, npjglo, ktime=jt) 135 | 136 | dsdev(:,:) = SQRT ( DBLE(zvba2(:,:) - zvbar(:,:)*zvbar(:,:)) ) 137 | 138 | ierr = putvar(ncout, id_varout(1), REAL(dsdev), 1, npiglo, npjglo, ktime=jt) 139 | END DO 140 | 141 | 142 | ierr = closeout(ncout) 143 | 144 | CONTAINS 145 | 146 | SUBROUTINE CreateOutput 147 | !!--------------------------------------------------------------------- 148 | !! *** ROUTINE CreateOutput *** 149 | !! 150 | !! ** Purpose : Create netcdf output file(s) 151 | !! 152 | !! ** Method : Use stypvar global description of variables 153 | !! 154 | !!---------------------------------------------------------------------- 155 | ipko(1) = 1 156 | stypvaro(1)%ichunk = (/npiglo, MAX(1,npjglo/30), 1, 1 /) 157 | stypvaro(1)%cname = TRIM(cv_in)//'_rms' 158 | stypvaro(1)%cunits = 'm' 159 | stypvaro(1)%rmissing_value = 0. 160 | stypvaro(1)%valid_min = 0. 161 | stypvaro(1)%valid_max = 100. 162 | stypvaro(1)%clong_name = 'RMS_Sea_Surface_height' 163 | stypvaro(1)%cshort_name = TRIM(cv_in)//'_rms' 164 | stypvaro(1)%conline_operation = 'N/A' 165 | stypvaro(1)%caxis = 'TYX' 166 | 167 | ncout = create (cf_out, cf_in, npiglo, npjglo, npk , ld_nc4=lnc4 ) 168 | ierr = createvar (ncout, stypvaro, 1, ipko, id_varout , ld_nc4=lnc4 ) 169 | ierr = putheadervar(ncout, cf_in, npiglo, npjglo, npk ) 170 | 171 | dtim = getvar1d(cf_in, cn_vtimec, npt ) 172 | ierr = putvar1d(ncout, dtim, npt, 'T') 173 | 174 | END SUBROUTINE CreateOutput 175 | 176 | END PROGRAM cdfrmsssh 177 | -------------------------------------------------------------------------------- /src/cdfstdevw.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfstdevw 2 | !!====================================================================== 3 | !! *** PROGRAM cdfstdevw *** 4 | !!===================================================================== 5 | !! ** Purpose : Compute the RMS of W, from the mean squared value. 6 | !! 7 | !! ** Method : Read gridW and gridW2 and compute rms 8 | !! 9 | !! History : 2.1 : 11/2004 : J.M. Molines : Original code 10 | !! 3.0 : 05/2011 : J.M. Molines : Doctor norm + Lic. 11 | !! : 4.0 : 03/2017 : J.M. Molines 12 | !!---------------------------------------------------------------------- 13 | USE cdfio 14 | USE modcdfnames 15 | !!---------------------------------------------------------------------- 16 | !! CDFTOOLS_4.0 , MEOM 2017 17 | !! $Id$ 18 | !! Copyright (c) 2017, J.-M. Molines 19 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 20 | !! @class statistics 21 | !!---------------------------------------------------------------------- 22 | IMPLICIT NONE 23 | 24 | INTEGER(KIND=4) :: jk, jt ! dummy loop index 25 | INTEGER(KIND=4) :: narg, iargc ! command line 26 | INTEGER(KIND=4) :: ijarg ! command line 27 | INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain 28 | INTEGER(KIND=4) :: npk, npt ! size of the domain 29 | INTEGER(KIND=4) :: ncout ! ncid of output variable 30 | INTEGER(KIND=4) :: ierr ! error status 31 | INTEGER(KIND=4), DIMENSION(1) :: ipko, id_varout ! output variable 32 | 33 | REAL(KIND=4) :: rmiss ! missing value attribute 34 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: zvbar, zvba2 ! mean and mean2 variable 35 | 36 | REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: dtim ! time counter 37 | REAL(KIND=8), DIMENSION(:,:), ALLOCATABLE :: dsdev ! standard deviation 38 | 39 | CHARACTER(LEN=256) :: cf_in ! input mean file name 40 | CHARACTER(LEN=256) :: cf_in2 ! input mean2 file name 41 | CHARACTER(LEN=256) :: cf_out = 'rmsw.nc'! output file name 42 | CHARACTER(LEN=256) :: cv_in, cv_in2 ! input variable names 43 | CHARACTER(LEN=256) :: cldum ! dummy character variable 44 | CHARACTER(LEN=256) :: cl_units, cl_longname, cl_shortname 45 | 46 | TYPE(variable), DIMENSION(1) :: stypvaro ! output data structure 47 | 48 | LOGICAL :: lchk = .FALSE. ! flag for missing files 49 | LOGICAL :: lnc4 = .FALSE. ! flag for netcdf4 with chunking and deflation 50 | !!---------------------------------------------------------------------- 51 | CALL ReadCdfNames() 52 | 53 | cv_in = cn_vovecrtz 54 | cv_in2 = TRIM(cn_vovecrtz)//'_sqd' 55 | 56 | narg= iargc() 57 | IF ( narg == 0 ) THEN 58 | PRINT *,' usage : cdfstdevw -w W-file -w2 W2-file [-o OUT-file] [-nc4] ...' 59 | PRINT *,' .... [-var IN-var IN-var2]' 60 | PRINT *,' ' 61 | PRINT *,' PURPOSE :' 62 | PRINT *,' Compute the standard deviation of the vertical velocity from its mean' 63 | PRINT *,' value and its mean square value. If a variable name is given ,then ' 64 | PRINT *,' the standard deviation of this variable instead of the vertical ' 65 | PRINT *,' velocity.' 66 | PRINT *,' ' 67 | PRINT *,' ARGUMENTS :' 68 | PRINT *,' -w W-file : netcdf file with mean values for w or ' 69 | PRINT *,' -w2 W2-file : netcdf file with mean squared values for w or ' 70 | PRINT *,' ' 71 | PRINT *,' OPTIONS: ' 72 | PRINT *,' [-o OUT-file] : specify the name of the output file instead of ',TRIM(cf_out) 73 | PRINT *,' [-nc4 ] : Use netcdf4 output with chunking and deflation level 1' 74 | PRINT *,' This option is effective only if cdftools are compiled with' 75 | PRINT *,' a netcdf library supporting chunking and deflation.' 76 | PRINT *,' [-var IN-var IN-var2] : give name of mean variable if not ', TRIM(cn_vovecrtz) 77 | PRINT *,' and ',TRIM(cn_vovecrtz)//'_sqd' 78 | PRINT *,' ' 79 | PRINT *,' REQUIRED FILES :' 80 | PRINT *,' none' 81 | PRINT *,' ' 82 | PRINT *,' OUTPUT : ' 83 | PRINT *,' netcdf file : ', TRIM(cf_out) ,' (if IN-var specified, output file is rms_var.nc)' 84 | PRINT *,' variables : ', TRIM(cv_in)//'_rms, (or IN-var_rms) same unit than the input.' 85 | PRINT *,' ' 86 | PRINT *,' SEE ALSO :' 87 | PRINT *,' cdfstd, cdfrmsssh, cdfstdevts, cdfstats.' 88 | PRINT *,' ' 89 | STOP 90 | ENDIF 91 | 92 | ijarg = 1 93 | DO WHILE ( ijarg <= narg) 94 | CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 95 | SELECT CASE ( cldum ) 96 | CASE ( '-w' ) ; CALL getarg(ijarg, cf_in ) ; ijarg=ijarg+1 97 | CASE ( '-w2' ) ; CALL getarg(ijarg, cf_in2) ; ijarg=ijarg+1 98 | ! options 99 | CASE ( '-o' ) ; CALL getarg(ijarg, cf_out) ; ijarg=ijarg+1 100 | CASE ( '-nc4' ) ; lnc4 = .TRUE. 101 | CASE ( '-var' ) ; CALL getarg(ijarg, cv_in ) ; ijarg=ijarg+1 ; cf_out='rms_'//TRIM(cv_in)//'.nc' 102 | ; ; CALL getarg(ijarg, cv_in2) ; ijarg=ijarg+1 103 | CASE DEFAULT ; PRINT *,' ERROR : ',TRIM(cldum),' : unknown option.' ; STOP 99 104 | END SELECT 105 | ENDDO 106 | 107 | ! check existence of files 108 | lchk = lchk .OR. chkfile(cf_in ) 109 | lchk = lchk .OR. chkfile(cf_in2) 110 | IF (lchk ) STOP 99 ! missing file 111 | 112 | npiglo = getdim (cf_in, cn_x) 113 | npjglo = getdim (cf_in, cn_y) 114 | npk = getdim (cf_in, cn_z) 115 | npt = getdim (cf_in, cn_t) 116 | 117 | PRINT *, 'npiglo = ', npiglo 118 | PRINT *, 'npjglo = ', npjglo 119 | PRINT *, 'npk = ', npk 120 | PRINT *, 'npt = ', npt 121 | 122 | CALL CreateOutput 123 | 124 | ALLOCATE( zvbar(npiglo,npjglo), zvba2(npiglo,npjglo) ) 125 | ALLOCATE( dsdev(npiglo,npjglo) ) 126 | 127 | ierr = getvaratt(cf_in, cv_in, cl_units, rmiss, cl_longname, cl_shortname ) 128 | 129 | DO jt = 1, npt 130 | DO jk = 1, npk 131 | zvbar(:,:) = getvar(cf_in, cv_in, jk, npiglo, npjglo, ktime=jt) 132 | zvba2(:,:) = getvar(cf_in2, cv_in2, jk, npiglo, npjglo, ktime=jt) 133 | 134 | dsdev(:,:) = SQRT ( DBLE(zvba2(:,:) - zvbar(:,:)*zvbar(:,:)) ) 135 | 136 | ierr = putvar(ncout, id_varout(1), REAL(dsdev), jk, npiglo, npjglo, ktime=jt) 137 | END DO 138 | END DO 139 | 140 | ierr = closeout(ncout) 141 | 142 | CONTAINS 143 | 144 | SUBROUTINE CreateOutput 145 | !!--------------------------------------------------------------------- 146 | !! *** ROUTINE CreateOutput *** 147 | !! 148 | !! ** Purpose : Create netcdf output file(s) 149 | !! 150 | !! ** Method : Use stypvar global description of variables 151 | !! 152 | !!---------------------------------------------------------------------- 153 | ipko(1) = npk 154 | stypvaro(1)%ichunk = (/ npiglo, MAX(1,npjglo/30), 1,1 /) 155 | stypvaro(1)%cname = TRIM(cv_in)//'_rms' 156 | stypvaro(1)%cunits = TRIM(cl_units) 157 | stypvaro(1)%rmissing_value = 0. 158 | stypvaro(1)%valid_min = 0. 159 | stypvaro(1)%valid_max = 10. 160 | stypvaro(1)%clong_name = 'RMS_'//TRIM(cl_longname) 161 | stypvaro(1)%cshort_name = TRIM(cv_in)//'_rms' 162 | stypvaro(1)%conline_operation = 'N/A' 163 | stypvaro(1)%caxis = 'TZYX' 164 | 165 | ncout = create (cf_out, cf_in, npiglo, npjglo, npk , ld_nc4=lnc4 ) 166 | ierr = createvar (ncout, stypvaro, 1, ipko, id_varout , ld_nc4=lnc4 ) 167 | ierr = putheadervar(ncout, cf_in, npiglo, npjglo, npk ) 168 | 169 | ALLOCATE( dtim(npt) ) 170 | dtim = getvar1d(cf_in, cn_vtimec, npt ) 171 | ierr = putvar1d(ncout, dtim, npt, 'T') 172 | 173 | END SUBROUTINE CreateOutput 174 | 175 | END PROGRAM cdfstdevw 176 | -------------------------------------------------------------------------------- /src/cdfsigntr.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfsigntr 2 | !!====================================================================== 3 | !! *** PROGRAM cdfsigntr *** 4 | !!===================================================================== 5 | !! ** Purpose : Compute ntr volumic mass 3D field from gridT file 6 | !! Store the results on a 'similar' cdf file. 7 | !! 8 | !! ** Method : Use Mc Dougall Jackett EOS (2005) 9 | !! 10 | !! History : 3.0 : 06/2013 : J.M. Molines from G. Madec idl code 11 | !! : 4.0 : 03/2017 : J.M. Molines 12 | !!---------------------------------------------------------------------- 13 | USE cdfio 14 | USE eos 15 | USE modcdfnames 16 | !!---------------------------------------------------------------------- 17 | !! CDFTOOLS_4.0 , MEOM 2017 18 | !! $Id$ 19 | !! Copyright (c) 2017, J.-M. Molines 20 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 21 | !! @class Equation_of_state 22 | !!---------------------------------------------------------------------- 23 | IMPLICIT NONE 24 | 25 | INTEGER(KIND=4) :: jk, jt ! dummy loop index 26 | INTEGER(KIND=4) :: ierr ! error status 27 | INTEGER(KIND=4) :: narg, iargc, ijarg ! browse command line 28 | INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain 29 | INTEGER(KIND=4) :: npk, npt ! size of the domain 30 | INTEGER(KIND=4) :: ncout ! ncid of output file 31 | INTEGER(KIND=4), DIMENSION(1) :: ipk, id_varout ! level and varid's 32 | 33 | REAL(KIND=4) :: zsps ! missing value for salinity 34 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: ztemp ! temperature 35 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: zsal ! salinity 36 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: zsigntr ! sigma-0 37 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: zmask ! 2D mask at current level 38 | 39 | REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: dtim ! time counter 40 | 41 | CHARACTER(LEN=256) :: cf_tfil ! input filename 42 | CHARACTER(LEN=256) :: cf_sfil ! salinity file (option) 43 | CHARACTER(LEN=256) :: cldum ! working variable 44 | CHARACTER(LEN=256) :: cf_out='signtr.nc' ! output file name 45 | 46 | TYPE (variable), DIMENSION(1) :: stypvar ! structure for attributes 47 | 48 | LOGICAL :: lnc4 = .FALSE. ! Use nc4 with chunking and deflation 49 | LOGICAL :: ll_teos10 = .FALSE. ! teos10 flag 50 | !!---------------------------------------------------------------------- 51 | CALL ReadCdfNames() 52 | 53 | narg = iargc() 54 | IF ( narg == 0 ) THEN 55 | PRINT *,' usage : cdfsigntr -t T-file [-s S-file] [-o OUT-file] [-nc4] [-teos10] ' 56 | PRINT *,' ' 57 | PRINT *,' PURPOSE :' 58 | PRINT *,' Compute neutral volumic mass (kg/m3) from temperature and salinity.' 59 | PRINT *,' ' 60 | PRINT *,' ARGUMENTS :' 61 | PRINT *,' -t T-file : netcdf file with temperature and salinity.' 62 | PRINT *,' If salinity not in T-file, use -s option.' 63 | PRINT *,' ' 64 | PRINT *,' OPTIONS :' 65 | PRINT *,' [-s S-file ] : Specify salinity file if not T-file.' 66 | PRINT *,' [-o OUT-file ] : Specify output file name instead of ', TRIM(cf_out) 67 | PRINT *,' [-nc4 ] : Use netcdf4 output with chunking and deflation level 1.' 68 | PRINT *,' This option is effective only if cdftools are compiled with' 69 | PRINT *,' a netcdf library supporting chunking and deflation.' 70 | PRINT *,' [-teos10] : use TEOS10 equation of state instead of default EOS80' 71 | PRINT *,' Temperature should be conservative temperature (CT) in deg C.' 72 | PRINT *,' Salinity should be absolute salinity (SA) in g/kg.' 73 | PRINT *,' ' 74 | PRINT *,' OPENMP SUPPORT : yes' 75 | PRINT *,' ' 76 | PRINT *,' REQUIRED FILES :' 77 | PRINT *,' none' 78 | PRINT *,' ' 79 | PRINT *,' OUTPUT : ' 80 | PRINT *,' netcdf file : ', TRIM(cf_out) ,' unless option -o is used.' 81 | PRINT *,' variables : ', TRIM(cn_vosigntr), ' ( kg/m3 )' 82 | PRINT *,' ' 83 | PRINT *,' SEE ALSO :' 84 | PRINT *,' cdfsig0, cdfsigi, cdfsiginsitu, cdfspice' 85 | STOP 86 | ENDIF 87 | 88 | ijarg=1 89 | cf_sfil='none' 90 | DO WHILE ( ijarg <= narg ) 91 | CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 92 | SELECT CASE ( cldum ) 93 | CASE ( '-t' ) ; CALL getarg (ijarg, cf_tfil ) ; ijarg=ijarg+1 94 | ! options 95 | CASE ( '-s' ) ; CALL getarg (ijarg, cf_sfil ) ; ijarg=ijarg+1 96 | CASE ( '-o' ) ; CALL getarg (ijarg, cf_out ) ; ijarg=ijarg+1 97 | CASE ( '-nc4' ) ; lnc4 = .TRUE. 98 | CASE ( '-teos10' ) ; ll_teos10 = .TRUE. 99 | CASE DEFAULT ; PRINT *,' ERROR : ', TRIM(cldum),' : unknown option.' ; STOP 99 100 | END SELECT 101 | ENDDO 102 | 103 | IF ( ll_teos10 ) THEN 104 | PRINT *," Sorry, cdfsigntr not yet coded for TEOS10 equation of state" 105 | PRINT *," Stay tuned .... " 106 | STOP 107 | ENDIF 108 | 109 | CALL eos_init ( ll_teos10 ) 110 | 111 | IF ( cf_sfil == 'none' ) cf_sfil=cf_tfil 112 | 113 | IF (chkfile(cf_tfil) .OR. chkfile(cf_sfil) ) STOP 99 ! missing file 114 | 115 | npiglo = getdim (cf_tfil, cn_x) 116 | npjglo = getdim (cf_tfil, cn_y) 117 | npk = getdim (cf_tfil, cn_z) 118 | npt = getdim (cf_tfil, cn_t) 119 | 120 | PRINT *, 'npiglo = ', npiglo 121 | PRINT *, 'npjglo = ', npjglo 122 | PRINT *, 'npk = ', npk 123 | PRINT *, 'npt = ', npt 124 | 125 | ALLOCATE (ztemp(npiglo,npjglo), zsal (npiglo,npjglo) ) 126 | ALLOCATE (zsigntr(npiglo,npjglo), zmask(npiglo,npjglo) ) 127 | ALLOCATE (dtim(npt) ) 128 | 129 | CALL CreateOutput 130 | zsps = getspval( cf_sfil, cn_vosaline ) 131 | 132 | DO jt=1,npt 133 | PRINT *,' TIME = ', jt, dtim(jt)/86400.,' days' 134 | DO jk = 1, npk 135 | PRINT *, 'level : ', jk 136 | zmask(:,:)=1. 137 | 138 | ztemp(:,:)= getvar(cf_tfil, cn_votemper, jk, npiglo, npjglo, ktime=jt) 139 | zsal(:,:) = getvar(cf_sfil, cn_vosaline, jk, npiglo, npjglo, ktime=jt) 140 | 141 | WHERE( zsal == zsps ) zmask = 0.0 142 | 143 | zsigntr(:,:) = sigmantr (ztemp, zsal, npiglo, npjglo )* zmask(:,:) 144 | 145 | ierr = putvar(ncout, id_varout(1), zsigntr, jk, npiglo, npjglo, ktime=jt) 146 | 147 | END DO ! loop to next level 148 | END DO ! next time frame 149 | 150 | ierr = closeout(ncout) 151 | CONTAINS 152 | 153 | SUBROUTINE CreateOutput 154 | !!--------------------------------------------------------------------- 155 | !! *** ROUTINE CreateOutput *** 156 | !! 157 | !! ** Purpose : Create netcdf output file(s) 158 | !! 159 | !! ** Method : Use stypvar global description of variables 160 | !! 161 | !!---------------------------------------------------------------------- 162 | ipk(:) = npk ! all variables (input and output are 3D) 163 | stypvar(1)%ichunk = (/npiglo,MAX(1,npjglo/30),1,1 /) 164 | stypvar(1)%cname = cn_vosigntr 165 | stypvar(1)%cunits = 'kg/m3' 166 | stypvar(1)%rmissing_value = 0. 167 | stypvar(1)%valid_min = 0.001 168 | stypvar(1)%valid_max = 1040. 169 | stypvar(1)%clong_name = 'Neutral volumic mass' 170 | stypvar(1)%cshort_name = cn_vosigntr 171 | stypvar(1)%conline_operation = 'N/A' 172 | stypvar(1)%caxis = 'TZYX' 173 | 174 | ! create output fileset 175 | ncout = create (cf_out, cf_tfil, npiglo, npjglo, npk , ld_nc4=lnc4 ) 176 | ierr = createvar (ncout, stypvar, 1, ipk, id_varout , ld_nc4=lnc4 ) 177 | ierr = putheadervar(ncout, cf_tfil, npiglo, npjglo, npk ) 178 | 179 | dtim=getvar1d(cf_tfil, cn_vtimec, npt ) 180 | ierr=putvar1d(ncout, dtim, npt, 'T') 181 | 182 | END SUBROUTINE CreateOutput 183 | 184 | END PROGRAM cdfsigntr 185 | -------------------------------------------------------------------------------- /src/cdfcsp.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfcsp 2 | !!====================================================================== 3 | !! *** PROGRAM cdfcsp *** 4 | !!===================================================================== 5 | !! ** Purpose : Replace the masked part of the arrays (marked with 6 | !! special values) with spval zero. Replace consistently 7 | !! the definition of the spval in the variable attribut. 8 | !! 9 | !! History : 2.1 : 10/2006 : F. Castruccio : Original code 10 | !! 3.0 : 12/2010 : J.M. Molines : Doctor norm + Lic. 11 | !! : 4.0 : 03/2017 : J.M. Molines 12 | !!---------------------------------------------------------------------- 13 | USE cdfio 14 | USE modcdfnames 15 | !!---------------------------------------------------------------------- 16 | !! CDFTOOLS_4.0 , MEOM 2017 17 | !! $Id$ 18 | !! Copyright (c) 2017, J.-M. Molines 19 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 20 | !! @class file_operations 21 | !!---------------------------------------------------------------------- 22 | IMPLICIT NONE 23 | 24 | INTEGER(KIND=4) :: jf, jk, jvar, jt ! dummy loop index 25 | INTEGER(KIND=4) :: narg, iargc ! 26 | INTEGER(KIND=4) :: ijarg ! 27 | INTEGER(KIND=4) :: nfiles ! number of files in the list 28 | INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain 29 | INTEGER(KIND=4) :: npk , npt ! size of the domain 30 | INTEGER(KIND=4) :: ncid, ierr ! ncdf related integer 31 | INTEGER(KIND=4) :: nvars ! Number of variables in a file 32 | INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: ipk ! arrays of vertical level for each var 33 | INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: id_var ! arrays of var id 34 | 35 | REAL(KIND=4), DIMENSION (:,:), ALLOCATABLE :: tab ! working array 36 | REAL(KIND=4) :: zspval ! special value read in file 37 | REAL(KIND=4) :: spval=0. ! special value written in file 38 | 39 | CHARACTER(LEN=256) :: cf_in ! input file name 40 | CHARACTER(LEN=256) :: cunits ! units attribute 41 | CHARACTER(LEN=256) :: clname ! long name attribute 42 | CHARACTER(LEN=256) :: csname ! short name attribute 43 | CHARACTER(LEN=256) :: cldum ! working char variable 44 | CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: cv_names ! array of var name 45 | CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: cf_lst ! list of input files 46 | 47 | TYPE(variable), DIMENSION(:), ALLOCATABLE :: stypvar ! type for attributes 48 | !!---------------------------------------------------------------------- 49 | CALL ReadCdfNames() 50 | 51 | narg = iargc() 52 | 53 | IF ( narg == 0 ) THEN 54 | PRINT *,' usage : cdfcsp -l LST-files [-v value]' 55 | PRINT *,' ' 56 | PRINT *,' PURPOSE :' 57 | PRINT *,' Replace missing_values by 0 and update attribute.' 58 | PRINT *,' This program is not working properly with NETCDF4/HDF5 files!' 59 | PRINT *,' Even more : problem when **compiled** with NETCDF4.' 60 | PRINT *,' ' 61 | PRINT *,' CAUTION :' 62 | PRINT *,' ################################' 63 | PRINT *,' # INPUT FILES ARE OVER-WRITTEN #' 64 | PRINT *,' ################################' 65 | PRINT *,' ' 66 | PRINT *,' ARGUMENTS :' 67 | PRINT *,' -l LST-files : The list of cdf file to process, all variables will ' 68 | PRINT *,' be processed.' 69 | PRINT *,' ' 70 | PRINT *,' OPTIONS :' 71 | PRINT *,' [-v value] : use value instead of 0 as the new missing_value' 72 | PRINT *,' ' 73 | PRINT *,' REQUIRED FILES :' 74 | PRINT *,' none' 75 | PRINT *,' ' 76 | PRINT *,' OUTPUT : ' 77 | PRINT *,' netcdf file : same as input file (modified)' 78 | PRINT *,' variables : same as input file' 79 | PRINT *,' ' 80 | STOP 81 | ENDIF 82 | 83 | !! Initialisation from 1st file (all file are assume to have the same geometry) 84 | ijarg=1 85 | DO WHILE ( ijarg <= narg ) 86 | CALL getarg( ijarg,cldum ) ; ijarg=ijarg+1 87 | SELECT CASE ( cldum ) 88 | CASE ( '-l' ) ; CALL GetFileList 89 | ! options 90 | CASE ( '-v' ) ; CALL getarg (ijarg, cldum ) ; ijarg=ijarg+1 ; READ(cldum,*) spval 91 | CASE DEFAULT ; PRINT *,' ERROR : ', TRIM(cldum) , ' : unknown option.' ; STOP 99 92 | END SELECT 93 | ENDDO 94 | cf_in = cf_lst(1) 95 | 96 | IF ( chkfile (cf_in) ) STOP 99 ! missing file 97 | 98 | npiglo = getdim (cf_in, cn_x) 99 | npjglo = getdim (cf_in, cn_y) 100 | npk = getdim (cf_in, cn_z, kstatus=ierr) 101 | npt = getdim (cf_in, cn_t) 102 | 103 | IF (ierr /= 0 ) THEN 104 | npk = getdim (cf_in,'z',kstatus=ierr) 105 | IF (ierr /= 0 ) THEN 106 | PRINT *, "ASSUME NO VERTICAL DIMENSIONS !" 107 | npk=0 108 | ENDIF 109 | ENDIF 110 | 111 | PRINT *, 'npiglo = ', npiglo 112 | PRINT *, 'npjglo = ', npjglo 113 | PRINT *, 'npk = ', npk 114 | PRINT *, 'npt = ', npt 115 | 116 | ALLOCATE( tab(npiglo,npjglo) ) 117 | 118 | nvars = getnvar(cf_in) 119 | 120 | ALLOCATE (cv_names(nvars), id_var(nvars),ipk(nvars), stypvar(nvars)) 121 | 122 | cv_names(:) = getvarname(cf_in, nvars, stypvar) 123 | ipk(:) = getipk (cf_in, nvars ) 124 | id_var(:) = getvarid (cf_in, nvars ) 125 | 126 | DO jf = 1, nfiles 127 | cf_in = cf_lst(jf) 128 | IF ( chkfile (cf_in) ) STOP 99 ! missing file 129 | PRINT *, 'Change spval on file ', cf_in 130 | ncid = ncopen(cf_in) 131 | npt = getdim (cf_in, cn_t) 132 | DO jvar = 1,nvars 133 | IF ( cv_names(jvar) == cn_vlon2d .OR. & 134 | & cv_names(jvar) == cn_vlat2d .OR. & 135 | & cv_names(jvar) == cn_vtimec .OR. & 136 | & cv_names(jvar) == cn_vdeptht .OR. & 137 | & cv_names(jvar) == cn_vdepthu .OR. & 138 | & cv_names(jvar) == cn_vdepthv ) THEN 139 | ! skip these variable 140 | ELSE 141 | ierr = getvaratt (cf_in, cv_names(jvar), cunits, zspval, clname, csname) 142 | ierr = cvaratt (cf_in, cv_names(jvar), cunits, spval, clname, csname) 143 | DO jt=1,npt 144 | DO jk = 1, ipk(jvar) 145 | tab(:,:) = getvar(cf_in, cv_names(jvar), jk, npiglo, npjglo, ktime=jt ) 146 | WHERE( tab(:,:) == zspval ) tab(:,:) = spval 147 | ierr = putvar(ncid, id_var(jvar), tab, jk, npiglo, npjglo, ktime=jt ) 148 | ENDDO 149 | END DO 150 | ENDIF 151 | ENDDO 152 | ENDDO 153 | 154 | ierr = closeout(ncid) 155 | 156 | CONTAINS 157 | 158 | SUBROUTINE GetFileList 159 | !!--------------------------------------------------------------------- 160 | !! *** ROUTINE GetFileList *** 161 | !! 162 | !! ** Purpose : Set up a file list given on the command line as 163 | !! blank separated list 164 | !! 165 | !! ** Method : Scan the command line until a '-' is found 166 | !!---------------------------------------------------------------------- 167 | INTEGER (KIND=4) :: ji 168 | INTEGER (KIND=4) :: icur 169 | !!---------------------------------------------------------------------- 170 | !! 171 | nfiles=0 172 | ! need to read a list of file ( number unknow ) 173 | ! loop on argument till a '-' is found as first char 174 | icur=ijarg ! save current position of argument number 175 | DO ji = icur, narg ! scan arguments till - found 176 | CALL getarg ( ji, cldum ) 177 | IF ( cldum(1:1) /= '-' ) THEN ; nfiles = nfiles+1 178 | ELSE ; EXIT 179 | ENDIF 180 | ENDDO 181 | ALLOCATE (cf_lst(nfiles) ) 182 | DO ji = icur, icur + nfiles -1 183 | CALL getarg(ji, cf_lst( ji -icur +1 ) ) ; ijarg=ijarg+1 184 | END DO 185 | END SUBROUTINE GetFileList 186 | 187 | END PROGRAM cdfcsp 188 | -------------------------------------------------------------------------------- /src/cdfsigi.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdfsigi 2 | !!====================================================================== 3 | !! *** PROGRAM cdfsigi *** 4 | !!===================================================================== 5 | !! ** Purpose : Compute sigmai 3D field from gridT file 6 | !! Store the results on a 'similar' cdf file. 7 | !! 8 | !! ** Method: read temp and salinity, compute sigma-i 9 | !! using depth given in argument (meters or dbar) 10 | !! 11 | !! History : 2.0 : 11/2004 : J.M. Molines : Original code 12 | !! 3.0 : 01/2011 : J.M. Molines : Doctor norm + Lic. 13 | !! : 4.0 : 03/2017 : J.M. Molines 14 | !!---------------------------------------------------------------------- 15 | USE cdfio 16 | USE eos 17 | USE modcdfnames 18 | !!---------------------------------------------------------------------- 19 | !! CDFTOOLS_4.0 , MEOM 2017 20 | !! $Id$ 21 | !! Copyright (c) 2017, J.-M. Molines 22 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 23 | !! @class Equation_of_state 24 | !!---------------------------------------------------------------------- 25 | IMPLICIT NONE 26 | 27 | INTEGER(KIND=4) :: jk, jt ! dummy loop index 28 | INTEGER(KIND=4) :: ierr ! error status 29 | INTEGER(KIND=4) :: narg, iargc, ijarg ! browse command line 30 | INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain 31 | INTEGER(KIND=4) :: npk, npt ! size of the domain 32 | INTEGER(KIND=4) :: ncout ! ncid of output file 33 | INTEGER(KIND=4), DIMENSION(1) :: ipk, id_varout ! level and varid's 34 | 35 | REAL(KIND=4) :: ref_dep ! reference depth in meters 36 | REAL(KIND=4) :: zspval ! missing value 37 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: ztemp ! temperature 38 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: zsal ! salinity 39 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: zsigi ! sigma-i 40 | REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: zmask ! 2D mask at current level 41 | 42 | REAL(KIND=8), DIMENSION(:), ALLOCATABLE :: dtim ! time counter 43 | 44 | CHARACTER(LEN=256) :: cf_tfil ! input filename 45 | CHARACTER(LEN=256) :: cf_sfil ! salinity file (option) 46 | CHARACTER(LEN=256) :: cf_out='sigi.nc' ! output file name 47 | CHARACTER(LEN=256) :: cldum ! dummy string 48 | 49 | TYPE (variable), DIMENSION(1) :: stypvar ! structure for attributes 50 | 51 | LOGICAL :: lnc4 = .FALSE. ! Use nc4 with chunking and deflation 52 | LOGICAL :: ll_teos10 = .FALSE. ! teos10 flag 53 | !!---------------------------------------------------------------------- 54 | CALL ReadCdfNames() 55 | 56 | narg = iargc() 57 | IF ( narg == 0 ) THEN 58 | PRINT *,' usage : cdfsigi -t T-file -r REF-dep(m) [-s S-file] [-o OUT-file] [-nc4]' 59 | PRINT *,' [-teos10] ' 60 | PRINT *,' ' 61 | PRINT *,' PURPOSE :' 62 | PRINT *,' Compute potential density referred to the depth given in arguments.' 63 | PRINT *,' ' 64 | PRINT *,' ARGUMENTS :' 65 | PRINT *,' -t T-file : netcdf file with temperature and salinity.' 66 | PRINT *,' If salinity not in T-file, use -s option.' 67 | PRINT *,' -r REF-dep : reference depth in meter.' 68 | PRINT *,' ' 69 | PRINT *,' OPTIONS :' 70 | PRINT *,' [-s S-file ] : Specify salinity file if not T-file.' 71 | PRINT *,' [-o OUT-file ] : Specify output file name instead of ',TRIM(cf_out) 72 | PRINT *,' [-nc4 ] : Use netcdf4 output with chunking and deflation level 1.' 73 | PRINT *,' This option is effective only if cdftools are compiled with' 74 | PRINT *,' a netcdf library supporting chunking and deflation.' 75 | PRINT *,' [-teos10] : use TEOS10 equation of state instead of default EOS80' 76 | PRINT *,' Temperature should be conservative temperature (CT) in deg C.' 77 | PRINT *,' Salinity should be absolute salinity (SA) in g/kg.' 78 | PRINT *,' ' 79 | PRINT *,' REQUIRED FILES :' 80 | PRINT *,' none' 81 | PRINT *,' ' 82 | PRINT *,' OUTPUT : ' 83 | PRINT *,' netcdf file : ', TRIM(cf_out) 84 | PRINT *,' variables : ', TRIM(cn_vosigmai),' (kg/m3 -1000 )' 85 | PRINT *,' ' 86 | PRINT *,' SEE ALSO :' 87 | PRINT *,' cdfsig0, cdfsiginintu' 88 | PRINT *,' ' 89 | STOP 90 | ENDIF 91 | 92 | ijarg=1 93 | cf_sfil='none' 94 | DO WHILE ( ijarg <= narg ) 95 | CALL getarg (ijarg, cldum ) ; ijarg=ijarg+1 96 | SELECT CASE ( cldum ) 97 | CASE ( '-t' ) ; CALL getarg (ijarg, cf_tfil) ; ijarg=ijarg+1 98 | CASE ( '-r' ) ; CALL getarg (ijarg, cldum ) ; ijarg=ijarg+1 ; READ(cldum,*) ref_dep 99 | ! options 100 | CASE ( '-s' ) ; CALL getarg (ijarg, cf_sfil) ; ijarg=ijarg+1 101 | CASE ( '-o' ) ; CALL getarg (ijarg, cf_out ) ; ijarg=ijarg+1 102 | CASE ( '-nc4' ) ; lnc4 = .TRUE. 103 | CASE ( '-teos10' ) ; ll_teos10 = .TRUE. 104 | CASE DEFAULT ; PRINT *,' ERROR : ', TRIM(cldum),' : unknown option.' ; STOP 99 105 | END SELECT 106 | ENDDO 107 | 108 | CALL eos_init ( ll_teos10 ) 109 | 110 | IF ( cf_sfil == 'none' ) cf_sfil=cf_tfil 111 | 112 | IF ( chkfile(cf_tfil) .OR. chkfile(cf_sfil) ) STOP 99 ! missing file 113 | 114 | npiglo = getdim (cf_tfil, cn_x) 115 | npjglo = getdim (cf_tfil, cn_y) 116 | npk = getdim (cf_tfil, cn_z) 117 | npt = getdim (cf_tfil, cn_t) 118 | 119 | PRINT *, 'npiglo = ', npiglo 120 | PRINT *, 'npjglo = ', npjglo 121 | PRINT *, 'npk = ', npk 122 | PRINT *, 'npt = ', npt 123 | 124 | ALLOCATE (ztemp(npiglo,npjglo), zsal (npiglo,npjglo) ) 125 | ALLOCATE (zsigi(npiglo,npjglo), zmask(npiglo,npjglo) ) 126 | ALLOCATE (dtim(npt) ) 127 | 128 | CALL CreateOutput 129 | zspval= getatt(cf_sfil, cn_vosaline, cn_missing_value) 130 | DO jt = 1, npt 131 | PRINT *,'time: ',jt 132 | DO jk = 1, npk 133 | zmask(:,:) = 1. 134 | 135 | ztemp(:,:) = getvar(cf_tfil, cn_votemper, jk, npiglo, npjglo, ktime=jt) 136 | zsal( :,:) = getvar(cf_sfil, cn_vosaline, jk, npiglo, npjglo, ktime=jt) 137 | 138 | WHERE( zsal == zspval ) zmask = 0 139 | 140 | zsigi(:,:) = sigmai(ztemp, zsal, ref_dep, npiglo, npjglo )* zmask(:,:) 141 | 142 | ierr = putvar(ncout, id_varout(1), zsigi, jk, npiglo, npjglo, ktime=jt) 143 | 144 | END DO ! loop to next level 145 | END DO ! loop on time 146 | 147 | ierr = closeout(ncout) 148 | CONTAINS 149 | 150 | SUBROUTINE CreateOutput 151 | !!--------------------------------------------------------------------- 152 | !! *** ROUTINE CreateOutput *** 153 | !! 154 | !! ** Purpose : Create netcdf output file(s) 155 | !! 156 | !! ** Method : Use stypvar global description of variables 157 | !! 158 | !!---------------------------------------------------------------------- 159 | ipk(:)= npk ! all variables (input and output are 3D) 160 | stypvar(1)%ichunk = (/npiglo,MAX(1,npjglo/30),1,1 /) 161 | stypvar(1)%cname = cn_vosigmai 162 | stypvar(1)%cunits = 'kg/m3' 163 | stypvar(1)%rmissing_value = 0. 164 | stypvar(1)%valid_min = 0.001 165 | stypvar(1)%valid_max = 45. 166 | stypvar(1)%clong_name = 'Potential_density:refered to '//TRIM(cldum)//' m' 167 | stypvar(1)%cshort_name = cn_vosigmai 168 | stypvar(1)%conline_operation = 'N/A' 169 | stypvar(1)%caxis = 'TZYX' 170 | 171 | ! create output fileset 172 | ncout = create (cf_out, cf_tfil, npiglo, npjglo, npk , ld_nc4=lnc4 ) 173 | ierr = createvar (ncout, stypvar, 1, ipk, id_varout , ld_nc4=lnc4 ) 174 | ierr = putheadervar(ncout, cf_tfil, npiglo, npjglo, npk ) 175 | 176 | dtim = getvar1d(cf_tfil, cn_vtimec, npt ) 177 | ierr = putvar1d(ncout, dtim, npt, 'T') 178 | 179 | END SUBROUTINE CreateOutput 180 | 181 | END PROGRAM cdfsigi 182 | -------------------------------------------------------------------------------- /src/cdficetrp.f90: -------------------------------------------------------------------------------- 1 | PROGRAM cdficetrp 2 | !!====================================================================== 3 | !! *** PROGRAM cdficetrp *** 4 | !!===================================================================== 5 | !! ** Purpose : compute ice transport across a section (either zonal 6 | !! or meridional. 7 | !! 8 | !! ** Method : read horizontal metrics, ice velocities, ice thickness 9 | !! and ice fraction. Then compute the following transport : 10 | !! icertrp = sum( ice_frac * ice_thickness * e1/2 * ice_vel ) 11 | !! 12 | !! History : 4.0 : 02/2018 : J.M. Molines : Original code 13 | !!---------------------------------------------------------------------- 14 | !!---------------------------------------------------------------------- 15 | !! routines : description 16 | !!---------------------------------------------------------------------- 17 | USE cdfio 18 | USE modcdfnames 19 | !!---------------------------------------------------------------------- 20 | !! CDFTOOLS_4.0 , MEOM 2018 21 | !! $Id$ 22 | !! Copyright (c) 2018, J.-M. Molines 23 | !! Software governed by the CeCILL licence (Licence/CDFTOOLSCeCILL.txt) 24 | !!---------------------------------------------------------------------- 25 | IMPLICIT NONE 26 | INTEGER(KIND=4) :: narg, iargc, ijarg 27 | INTEGER(KIND=4) :: nsection ! number of sections (overall) 28 | 29 | INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: iimina, iimaxa ! sections limits 30 | INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: ijmina, ijmaxa ! sections limits 31 | 32 | 33 | 34 | CHARACTER(LEN=255) :: cf_ifil ! input ice model 35 | CHARACTER(LEN=255) :: cf_sfil='ice_section.dat' ! input section file (txt) 36 | CHARACTER(LEN=255) :: cldum ! dummy character variable 37 | CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: csection ! section name 38 | CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: cvarname ! output variable name (root) 39 | CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: clongname ! output long name (root) 40 | 41 | 42 | LOGICAL :: lchk = .FALSE. 43 | LOGICAL :: lim3 = .FALSE. 44 | 45 | !!---------------------------------------------------------------------- 46 | CALL ReadCdfNames() 47 | narg = iargc() 48 | 49 | IF ( narg == 0 ) THEN 50 | PRINT *,' usage : cdficetrp -i ICE-file [-s SECTION-file]' 51 | PRINT *,' ' 52 | PRINT *,' PURPOSE :' 53 | PRINT *,' Compute ice transport through sections described into a section file,' 54 | PRINT *,' whose default name is ',TRIM(cf_sfil),'. This file has the ' 55 | PRINT *,' folowing format: It is a text file with pairs of lines foreach ' 56 | PRINT *,' section giving : (1) section name and (2) section location.' 57 | PRINT *,' ' 58 | PRINT *,' First line with section name may also have 2 additional strings holding' 59 | PRINT *,' a prefix for variable output, and a long name to be used as attribute in' 60 | PRINT *,' the output file. ' 61 | PRINT *,' Second line gives the location of the section with specification of four' 62 | PRINT *,' integer values (imin imax jmin jmax), relative to the model grid.' 63 | PRINT *,' Only zonal or meridional sections are allowed.' 64 | PRINT *,' ' 65 | PRINT *,' ARGUMENTS :' 66 | PRINT *,' -i ICE-file : specify ICE-file containing ice velocity, and' 67 | PRINT *,' ice concentration.' 68 | PRINT *,' ' 69 | PRINT *,' OPTIONS :' 70 | PRINT *,' [-s SECTION-file] : give the name of the section file, instead' 71 | PRINT *,' of default ',TRIM(cf_sfil) 72 | PRINT *,' ' 73 | PRINT *,' ' 74 | PRINT *,' REQUIRED FILES :' 75 | PRINT *,' mesh_hgr.nc and mask.nc' 76 | PRINT *,' ' 77 | PRINT *,' OUTPUT : ' 78 | PRINT *,' Netcdf file : There is 1 netcdf file per section. File name is build' 79 | PRINT *,' from section name :
_icetrp.nc' 80 | PRINT *,' variables : icetrp ' 81 | 82 | ! PRINT *,' netcdf file : ', TRIM(cf_out) 83 | ! PRINT *,' variables : ', TRIM(cv_out),' (Sv)' 84 | PRINT *,' ' 85 | PRINT *,' SEE ALSO : ' 86 | PRINT *,' cdftransport, cdficediags' 87 | PRINT *,' ' 88 | STOP 89 | ENDIF 90 | 91 | ! Parse command line 92 | ijarg = 1 93 | DO WHILE ( ijarg <= narg ) 94 | CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 95 | SELECT CASE ( cldum ) 96 | CASE ( '-i' ) ; CALL getarg(ijarg, cf_ifil ) ; ijarg=ijarg+1 97 | ! Option 98 | CASE ( '-s' ) ; CALL getarg(ijarg, cf_sfil ) ; ijarg=ijarg+1 99 | CASE DEFAULT ; PRINT *, ' ERROR : ', TRIM(cldum),' : unknown option.'; STOP 1 100 | END SELECT 101 | ENDDO 102 | 103 | ! Check existence of files : 104 | lchk = chkfile (cn_fhgr) .OR. lchk 105 | lchk = chkfile (cn_fmsk) .OR. lchk 106 | lchk = chkfile (cf_ifil) .OR. lchk 107 | lchk = chkfile (cf_sfil) .OR. lchk 108 | IF ( lchk ) STOP 99 ! missing file 109 | 110 | ! check if cf_ifile corresponds to lim3 or lim2 111 | IF ( chkvar ( cf_ifil, cn_ileadfra ,.FALSE. ) ) THEN 112 | lim3 = .FALSE. 113 | ELSE 114 | lim3 = .TRUE. 115 | cn_ileadfra = cn_ileadfra3 116 | cn_iicethic = cn_iicethic3 117 | cn_iicevelu = cn_iicevelu3 118 | cn_iicevelv = cn_iicevelv3 119 | ENDIF 120 | 121 | ! Initialise section 122 | nsection=0 123 | CALL section_init(cf_sfil, csection,cvarname,clongname,iimina, iimaxa, ijmina, ijmaxa, nsection) 124 | 125 | CONTAINS 126 | SUBROUTINE section_init(cdfile, cdsection, cdvarname, cdlongname, kimin, kimax, kjmin, kjmax, knumber) 127 | !!--------------------------------------------------------------------- 128 | !! *** ROUTINE section_init *** 129 | !! 130 | !! ** Purpose : Read input ASCII file that defines section names and limit of 131 | !! sections. 132 | !! 133 | !! ** Method : At fisrt call only return the number of sections for further 134 | !! allocation. 135 | !! 136 | !!---------------------------------------------------------------------- 137 | CHARACTER(LEN=*), INTENT(in ) :: cdfile 138 | CHARACTER(LEN=256), DIMENSION(knumber), INTENT(out ) :: cdsection 139 | CHARACTER(LEN=256), DIMENSION(knumber), INTENT(out ) :: cdvarname 140 | CHARACTER(LEN=256), DIMENSION(knumber), INTENT(out ) :: cdlongname 141 | INTEGER(KIND=4), INTENT(inout) :: knumber 142 | INTEGER(KIND=4), DIMENSION(knumber), INTENT(out ) :: kimin, kimax, kjmin, kjmax 143 | 144 | ! Local variables 145 | INTEGER(KIND=4) :: jsec 146 | INTEGER(KIND=4) :: ii, inum=10 147 | INTEGER(KIND=4) :: ipos 148 | CHARACTER(LEN=256) :: cline 149 | CHARACTER(LEN=80), DIMENSION(3) :: cldum 150 | LOGICAL :: llfirst 151 | !!---------------------------------------------------------------------- 152 | llfirst=.FALSE. 153 | IF ( knumber == 0 ) llfirst=.TRUE. 154 | 155 | OPEN(inum, FILE=cdfile) 156 | REWIND(inum) 157 | ii = 0 158 | 159 | ! read the file just to count the number of sections 160 | DO 161 | READ(inum,'(a)') cline 162 | IF (INDEX(cline,'EOF') == 0 ) THEN 163 | READ(inum,*) ! skip one line 164 | ii = ii + 1 165 | ELSE 166 | EXIT 167 | ENDIF 168 | END DO 169 | 170 | knumber=ii 171 | IF ( llfirst ) RETURN 172 | 173 | REWIND(inum) 174 | DO jsec=1,knumber 175 | READ(inum,'(a)') cline 176 | ii = 0 177 | cldum(:) = 'none' 178 | ipos = INDEX(cline,' ') 179 | DO WHILE ( ipos > 1 ) 180 | ii = ii + 1 181 | cldum(ii) = cline(1:ipos - 1 ) 182 | cline = TRIM ( cline(ipos+1:) ) 183 | ipos = INDEX( cline,' ' ) 184 | IF ( ii >= 3 ) EXIT 185 | END DO 186 | cdsection(jsec) = TRIM(cldum(1) ) 187 | cdvarname(jsec) = TRIM(cldum(2) ) 188 | cdlongname(jsec) = TRIM(cldum(3) ) 189 | READ(inum,* ) kimin(jsec), kimax(jsec), kjmin(jsec), kjmax(jsec) 190 | END DO 191 | 192 | CLOSE(inum) 193 | 194 | END SUBROUTINE section_init 195 | 196 | 197 | 198 | END PROGRAM cdficetrp 199 | --------------------------------------------------------------------------------