Commit 5fb5805d authored by gotm's avatar gotm

Initial revision

parents
None so far - but missing features.
But if you find any please e-mail to:
karsten@bolding-burchard.com
or
hans@bolding-burchard.com
This diff is collapsed.
$Id: CodingStyle,v 1.1 2002-05-02 14:00:27 gotm Exp $
In this file a few general rules for coding 'getm' are given.
0: Use of module, subroutine and function templates.
In the template directory example files of modules, subroutines and functions
are available. Please use those if you need to create a new file and please fill
in all relevant information - especially author and description.
1: Indentation
Since Fortran90 allows for free-format we don't have to stick to the column 7
rule. After a bit of testing we have chosen that each new level should be
indented 3 blanks e.g..
subroutine egon
logical is_it_true
integer i,j
kaj = 1
if (is_it_true) then
do i=1,100
j=i
end do
end if
return
end
And please don't put any blanks at the end of lines.
2: Upper and lower case.
We keep everything in lower case.
3: Variable naming conventions.
Highest priority is - readability - therefore we have chosen the C-style
convention - where we use _ instead of mixed upper/lower case variable names.
Variables - especially public variables - should have a meaningful name
like in 'have_boundaries'.
4: Writing diagnostics.
A few pre-processing definitions have been defined in cppdefs.h to ease writing
diagnostics and also to give diagnostics a consistent look. Have a look in
cppdefs.h for the actual definitions. Here is just one example:
Instead of coding:
write(0,*) 'Some diagnostic ouput'
use
STDERR 'Some diagnostic ouput'
This makes it very easy to change the entire diagnostic system in the program
by simply changing the definition of STDERR in cppdefs.h.
To allow for different identations the following set of definitions have been
implemented:
LEVEL0 to LEVEL4 they are to be used as STDERR.
5: Import explicitely variables from modules.
When other modules are used always use the 'ONLY' keyword and do only import
the variables actually needed. This give a much clearerpicture of the data
flow in the programme.
$Id: FAQ,v 1.1 2002-05-02 14:00:27 gotm Exp $
Initial version developed by Hans Burchard in the Matar MAST project.
The original code was not very generel and in order to apply it for
a different area quite a lot should be changed.
Shortly after Karsten Bolding started at JRC we decided to join forces
and turn the original code into a generel purpuse 3D model. The first
step was to remove all non-generel code from the original code. Second
step was to implement generel input-output routines. We decided to use
NETCDF as file format. Third step was to implement baroclinic effects.
In late July 1998 the first beta was ready - still with some missing
features - and was run for different simple test cases.
980724:
$Id: INSTALL,v 1.1 2002-05-02 14:00:28 gotm Exp $
#
# Master Makefile for the getm project.
#
VERSION = 1
PATCHLEVEL = 1
SUBLEVEL = 0
VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
EXEC = model$(libtype)
base = BUGS INSTALL README TODO HISTORY
all: VERSION $(EXEC) doc
$(EXEC): include/version.h
$(MAKE) -C src $(EXEC) install
include/version.h: ./Makefile
@echo \#define RELEASE \"$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)\" > .ver
@mv -f .ver $@
VERSION: ./Makefile
@echo $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@
doc:
$(MAKE) -C src/ doc
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i doc; done
clean:
rm -f VERSION
distclean:
$(MAKE) -C src distclean
$(MAKE) -C utils distclean
dist: distclean
(cd ../ ; tar cf - v$(VER)/ | gzip -9 > v$(VER).tar.gz)
sync
diff:
cvs diff > cvs.diff
vi cvs.diff
$(RM) cvs.diff
update:
cvs update > cvs.update
vi cvs.update
$(RM) cvs.update
cvs2cl
vi ChangeLog
commit:
cvs commit > cvs.commit
vi cvs.commit
dummy:
$Id: README,v 1.1 2002-05-02 14:00:28 gotm Exp $
$Id: README.compile,v 1.1 2002-05-02 14:00:29 gotm Exp $
To be written
$Id: TODO,v 1.1 2002-05-02 14:00:29 gotm Exp $
This is TeX, Version 3.14159 (Web2C 7.3.7) (format=latex 2001.12.11) 5 JAN 2002 18:08
**code_letter
(/usr/share/texmf/tex/latex/tools/.tex
! Interruption.
<to be read again>
\begingroup
l.1
%%
? X
Here is how much of TeX's memory you used:
5 strings out of 10847
122 string characters out of 70945
44507 words of memory out of 263001
3034 multiletter control sequences out of 10000+0
3640 words of font info for 14 fonts, out of 400000 for 1000
14 hyphenation exceptions out of 1000
3i,0n,1p,18b,6s stack positions out of 300i,100n,500p,50000b,4000s
No pages of output.
! This file is include in all .F90 files and contains very important
! difinitions. Infact the model will not compile when this file is not
! in a correct format.
! KBK 990615
#include "version.h"
#if defined(SPHERICAL) || defined(CURVILINEAR)
#define DXC dxc(i,j)
#define DXCJP1 dxc(i,j+1)
#define DXU dxu(i,j)
#define DXV dxv(i,j)
#define DXVJM1 dxv(i,j-1)
#define DXX dxx(i,j)
#define DXXJM1 dxx(i,j-1)
#define DYC dyc(i,j)
#define DYCIP1 dyc(i+1,j)
#define DYU dyu(i,j)
#define DYUIM1 dyu(i-1,j)
#define DYV dyv(i,j)
#define DYX dyx(i,j)
#define DYXIM1 dyx(i-1,j)
#define ARCD1 arcd1(i,j)
#define ARUD1 arud1(i,j)
#define ARVD1 arvd1(i,j)
#else
#define DXC dx
#define DXCJP1 dx
#define DXU dx
#define DXV dx
#define DXVJM1 dx
#define DXX dx
#define DXXJM1 dx
#define DYC dy
#define DYCIP1 dy
#define DYU dy
#define DYUIM1 dy
#define DYV dy
#define DYX dy
#define DYXIM1 dy
#define ARCD1 ard1
#define ARUD1 ard1
#define ARVD1 ard1
#endif
! Reserved Fortran units
#define stdin 5
#define stdout 6
#define stderr 0
#define debug 0
#define NAMLST 10
#define RESTART 15
#define PARSETUP 20
#define BDYINFO 21
#define BDYDATA 22
! Data/file formats
#define ANALYTICAL 0
#define ASCII 1
#define NETCDF 2
#define RAWBINARY 3
#define OPENDX 4
#define GRADS 5
#define PATH_MAX 255
! Handy for writing
#define STDOUT write(stdout,*)
#define STDERR write(stderr,*)
#define LEVEL0 STDERR
#define LEVEL1 STDERR ' ',
#define LEVEL2 STDERR ' ',
#define LEVEL3 STDERR ' ',
#define LEVEL4 STDERR ' ',
#define FATAL STDERR 'FATAL ERROR: ',
!KBK#define STDERR IF(myid.le.0) write(stderr,*)
#define LINE "------------------------------------------------------------------------"
! For easier reading
#define READING 0
#define WRITING 1
! To avoid dividing by zero
#define SMALL 1e-8
! What precision will we use in this compilation
#define SINGLE
#undef SINGLE
#ifdef SINGLE
#define REALTYPE REAL
#define REAL_SIZE 4
#define _ZERO_ 0.0
#define _ONE_ 1.0
#else
#define REALTYPE DOUBLE PRECISION
#define MPI_REALTYPE MPI_DOUBLE_PRECISION
#define REAL_SIZE 8
#define _ZERO_ 0.0d0
#define _ONE_ 1.0d0
#endif
! The width of the HALO zones
#define HALO 1
! Here the memory-allocation is defined
#define E2DFIELD imin-HALO:imax+HALO,jmin-HALO:jmax+HALO
#define I2DFIELD iimin-HALO:iimax+HALO,jjmin-HALO:jjmax+HALO
#define I3DFIELD iimin-HALO:iimax+HALO,jjmin-HALO:jjmax+HALO,0:kmax
! These defines the do loops for the real inner points..
! that is the points that are independent of neighbours.
#define DO_EILOOP DO i=imin,imax
#define DO_EJLOOP DO j=jmin,jmax
#define DO_IILOOP DO i=iimin,iimax
#define DO_IJLOOP DO j=jjmin,jjmax
#define RELEASE "1.1.0"
#$Id: Makefile,v 1.1 2002-05-02 14:00:41 gotm Exp $
#
# Makefile to build the 2D specific library - libm2d.a
#
include ../Rules.make
INCS = static.h dynamic_declarations.h dynamic_allocations.h
LIB = $(LIBDIR)/lib2d${buildtype}.a
MODSRC = m2d.F90 variables_2d.F90
LIBSRC = cfl_check.F90 have_bdy.F90 bottom_friction.F90 depth_update.F90 momentum.F90 uv_advect.F90 uv_diffusion.F90 coriolis.F90 sealevel.F90 uv_depths.F90 init_2d_bdy.F90 update_2d_bdy.F90 divergence.F90 residual.F90
SRC = $(MODSRC) $(LIBSRC)
MOD = \
${LIB}(variables_2d.o) \
${LIB}(m2d.o)
OBJ = \
${LIB}(cfl_check.o) \
${LIB}(bottom_friction.o) \
${LIB}(coriolis.o) \
${LIB}(depth_update.o) \
${LIB}(momentum.o) \
${LIB}(sealevel.o) \
${LIB}(uv_advect.o) \
${LIB}(uv_diffusion.o) \
${LIB}(uv_depths.o) \
${LIB}(have_bdy.o) \
${LIB}(divergence.o) \
${LIB}(residual.o) \
${LIB}(update_2d_bdy.o)
all: modules objects
modules: $(MOD)
objects: $(OBJ)
$(MOD): $(INCS)
$(OBJ): $(INCS)
doc:
$(PROTEX) $(SRC) > $(DOCDIR)/2d.tex
clean:
$(RM) $(LIB) $(MODDIR)/m2d.{m,mod}
realclean: clean
$(RM) *.o
distclean: realclean
#-----------------------------------------------------------------------
# Copyright (C) 2001 - Hans Burchard and Karsten Bolding (BBH) !
#-----------------------------------------------------------------------
!$Id: bottom_friction.F90,v 1.1 2002-05-02 14:00:41 gotm Exp $
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: bottom_friction() - calculates the 2D bottom friction.
!
! !INTERFACE:
subroutine bottom_friction(runtype)
!
! !DESCRIPTION:
!
! !USES:
use parameters, only: kappa,avmmol
use domain, only: imin,imax,jmin,jmax,au,av,min_depth
use variables_2d
IMPLICIT NONE
!
! !INPUT PARAMETERS:
integer, intent(in) :: runtype
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
! !REVISION HISTORY:
! Original author(s): Karsten Bolding & Hans Burchard
!
! $Log: bottom_friction.F90,v $
! Revision 1.1 2002-05-02 14:00:41 gotm
! Initial revision
!
! Revision 1.6 2001/06/22 08:19:10 bbh
! Compiler options such as USE_MASK and OLD_DRY deleted.
! Open and passive boundary for z created.
! Various inconsistencies removed.
! wait_halo added.
! Checked loop boundaries
!
! Revision 1.5 2001/05/20 07:46:38 bbh
! Fixed masks
!
! Revision 1.4 2001/05/18 13:03:34 bbh
! Optimize for speed + masks for update_2d_halo() - CHECK
!
! Revision 1.3 2001/05/03 19:35:01 bbh
! Use of variables_2d
!
! Revision 1.2 2001/04/24 08:24:58 bbh
! Use runtype instead of macro
!
! Revision 1.1.1.1 2001/04/17 08:43:08 bbh
! initial import into CVS
!
! !LOCAL VARIABLES:
integer :: i,j
REALTYPE :: uloc(E2DFIELD),vloc(E2DFIELD)
REALTYPE :: HH(E2DFIELD),fricvel(E2DFIELD)
!EOP
!-----------------------------------------------------------------------
!BOC
#ifdef DEBUG
integer, save :: Ncall = 0
Ncall = Ncall+1
write(debug,*) 'bottom_friction() # ',Ncall
#endif
where (au .gt. 0)
uloc=U/DU
end where
do j=jmin,jmax
do i=imin,imax
if (au(i,j) .gt. 0) then
vloc(i,j)=0.25* ( V(i ,j )/DV(i ,j ) &
+V(i+1,j )/DV(i+1,j ) &
+V(i ,j-1)/DV(i ,j-1) &
+V(i+1,j-1)/DV(i+1,j-1) )
end if
end do
end do
! The x-direction
#ifndef DEBUG
where (au .gt. 0)
HH=max(min_depth,DU)
ruu=(kappa/log((zub+0.5*HH)/zub))**2
end where
#else
HH=max(min_depth,DU)
ruu=(zub+0.5*HH)/zub
do j=jmin,jmax
do i=imin,imax
if (ruu(i,j) .le. _ONE_) then
STDERR 'bottom_friction friction coefficient infinite.'
STDERR 'i = ',i,' j = ',j
STDERR 'min_depth = ',min_depth,' DU = ',DU(i,j)
stop
end if
end do
end do
where (au .gt. 0)
ruu=(kappa/log(ruu))**2
end where
#endif
if (runtype .eq. 1) then
where (au .gt. 0)
fricvel=sqrt(ruu*(uloc**2+vloc**2))
zub=min(HH,zub0+0.1*avmmol/max(avmmol,fricvel))
ruu=(zub+0.5*HH)/zub
ruu=(kappa/log(ruu))**2
end where
end if
where (au .gt. 0)
ru=ruu*sqrt(uloc**2+vloc**2)
end where
! The y-direction
do j=jmin,jmax
do i=imin,imax
if (av(i,j) .gt. 0) then
uloc(i,j)=0.25* ( U(i ,j )/DU(i ,j ) &
+U(i-1,j )/DU(i-1,j ) &
+U(i ,j+1)/DU(i ,j+1) &
+U(i-1,j+1)/DU(i-1,j+1) )
end if
end do
end do
where (av .gt. 0)
vloc=V/DV
end where
#ifndef DEBUG
where (av .gt. 0)
HH=max(min_depth,DV)
rvv=(kappa/log((zvb+0.5*HH)/zvb))**2
end where
#else
HH=max(min_depth,DV)
rvv=(zvb+0.5*HH)/zvb
do j=jmin,jmax
do i=imin,imax
if (rvv(i,j) .le. _ONE_) then
STDERR 'bottom_friction friction coefficient infinite.'
STDERR 'i = ',i,' j = ',j
STDERR 'min_depth = ',min_depth,' DV = ',DU(i,j)
stop
end if
end do
end do
where (av .gt. 0)
rvv=(kappa/log(rvv))**2
end where
#endif
where (av .gt. 0)
HH=max(min_depth,DV)
rvv=(kappa/log((zvb+0.5*HH)/zvb))**2
end where
! if (runtype .eq. 1) then
where (av .gt. 0)
fricvel=sqrt(rvv*(uloc**2+vloc**2))
! zvb=min(HH,zvb0+0.1*avmmol/max(avmmol,fricvel))
rvv=(zvb+0.5*HH)/zvb
rvv=(kappa/log(rvv))**2
end where
! end if
where (av .gt. 0)
rv=rvv*sqrt(uloc**2+vloc**2)
end where
#ifdef DEBUG
write(debug,*) 'Leaving bottom_friction()'
write(debug,*)
#endif
return
end subroutine bottom_friction
!EOC
!-----------------------------------------------------------------------
! Copyright (C) 2001 - Hans Burchard and Karsten Bolding !
!-----------------------------------------------------------------------
!$Id: cfl_check.F90,v 1.1 2002-05-02 14:00:41 gotm Exp $
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
! !ROUTINE: cfl_check() - barotropic residual currents.
!
! !INTERFACE:
subroutine cfl_check()
!
! !DESCRIPTION:
!
! !USES:
use parameters, only: g
use domain, only: imin,imax,jmin,jmax,H,az
#if defined(SPHERICAL) || defined(CURVILINEAR)
use domain, only: dyc,dxc
#else
use domain, only: dy,dx
#endif
use m2d, only: dtm
IMPLICIT NONE
!
! !INPUT PARAMETERS:
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
! !REVISION HISTORY:
! Original author(s): Karsten Bolding & Hans Burchard
!
! $Log: cfl_check.F90,v $
! Revision 1.1 2002-05-02 14:00:41 gotm
! Initial revision
!
! Revision 1.7 2001/09/19 11:25:14 gotm
! Removed E2DFIELD when de-allocating lmask
!
! Revision 1.6 2001/09/19 11:20:32 bbh