Commit 942e0016 authored by gotm's avatar gotm
Browse files

added utils dir

parent 55a7fcfa
......@@ -34,6 +34,7 @@ clean:
distclean:
$(MAKE) -C src distclean
$(MAKE) -C utils distclean
$(RM) -r bin
dist: distclean
(cd ../ ; tar cf - v$(VER)/ | gzip -9 > v$(VER).tar.gz)
......
#$Id: Makefile,v 1.1 2003-04-03 06:11:26 gotm Exp $
#---------------------------------------------------------------------+
#
# Makefile for various getm utilities
#
#---------------------------------------------------------------------+
include $(GETMDIR)/src/Rules.make
LDFLAGS = -L/opt/netcdf/lib -L$(GETMDIR)/lib/$(FORTRAN_COMPILER)
FLIBS = -lfutils_prod $(NETCDFLIBNAME) -lm -lPEPCF90
FFLAGS = -O -I$(NETCDFINC) -I$(GETMDIR)/modules/$(FORTRAN_COMPILER)
F90FLAGS= $(FFLAGS)
FOBJS = tide.o gen_bdy_ncdf.o
PROGS = make_tides
BINDIR = ../bin
all: $(PROGS) install
make_tides: make_tides.o $(FOBJS)
@ echo "Making $@ ..."
$(FC) -o $@ $@.o $(LDFLAGS) $(FOBJS) $(FLIBS)
install: $(PROGS)
mkdir -p $(BINDIR)
mv $(PROGS) $(BINDIR)
doc: html man
html: $(PROG).pod
pod2html $(PROG).pod
$(MV) $(PROG).html $(htmldir)
man: $(PROG).pod
pod2man $(PROG).pod > $(PROG).1
$(MV) $(PROG).1 $(mandir)
clean:
$(RM) *.o
realclean: clean
$(RM) -f $(PROGS)
distclean: realclean
$(RM) -f *.c~ *.h~
%.o: %.F
$(FC) $(F90FLAGS) $(EXTRA_FFLAGS) -c $< -o $@
c-----------------------------------------------------------------------
c extended_max : nombre max d'ondes prises en compte
c delta_max : intervalle en heure de recalcul des corrections nodales
c-----------------------------------------------------------------------
integer extended_max
real*8 pi,delta_max,t_nodal
character*6 wave
character*20 model
real*8 freq
real*8 n,p,s,p1,pp,nu,xi,tt,nuprim,nusec,hp,r,iang,x1ra
parameter (extended_max=13)
parameter (pi = 3.141592653589793d+00)
parameter (delta_max=24.D+00)
common/wave/ nbwave,f(extended_max),
& v0_u(extended_max),num(extended_max),
& sreal(extended_max),
& simag(extended_max),wave(extended_max)
common/wave2/ freq(extended_max)
common/grid/ ni,nj,xmin,ymin,dx,dy
common/model/ wrp(0:721,361,extended_max),
& wip(0:721,361,extended_max),spec
common/model_name/ model
common/nodal/ n,p,s,p1,pp,nu,xi,tt,nuprim,nusec,hp,r,iang,
& x1ra,t_nodal
!$Id: gen_bdy_ncdf.F90,v 1.1 2003-04-03 06:11:26 gotm Exp $
subroutine create_nc_file(fn,nbdyp,ts,ncid,time_id,jul_id,secs_id,elev_id)
implicit none
character(len=*), intent(in) :: fn
integer, intent(in) :: nbdyp
character(len=*), intent(in) :: ts
integer, intent(out) :: ncid,time_id,jul_id,secs_id,elev_id
include 'netcdf.inc'
integer nbdyp_len
integer, parameter :: time_len = NF_UNLIMITED
integer nbdyp_dim, time_dim
integer time_dims(1)
integer elev_dims(2)
real realval(1)
integer iret
character(len=80) :: string
nbdyp_len = nbdyp
iret = nf_create(trim(fn), NF_CLOBBER, ncid)
!kbk call check_err(iret)
write(0,*) ncid
iret = nf_def_dim(ncid, 'nbdyp', nbdyp_len, nbdyp_dim)
!kbkcall check_err(iret)
iret = nf_def_dim(ncid, 'time', NF_UNLIMITED, time_dim)
!kbkcall check_err(iret)
time_dims(1) = time_dim
iret = nf_def_var(ncid, 'time', NF_REAL, 1, time_dims, time_id)
iret = nf_def_var(ncid, 'julday', NF_INT, 1, time_dims, jul_id)
iret = nf_def_var(ncid, 'secs', NF_INT, 1, time_dims, secs_id)
elev_dims(2) = time_dim
elev_dims(1) = nbdyp_dim
iret = nf_def_var(ncid, 'elev', NF_REAL, 2, elev_dims, elev_id)
!kbk call check_err(iret)
string = 'seconds since '//trim(ts)
iret = nf_put_att_text(ncid,time_id, 'units', len_trim(string), trim(string))
!kbk call check_err(iret)
iret = nf_put_att_text(ncid, jul_id, 'long_name', 15, 'true julian day')
iret = nf_put_att_text(ncid, jul_id, 'units', 4, 'days')
iret = nf_put_att_text(ncid, secs_id, 'long_name', 22, 'seconds since midnight')
iret = nf_put_att_text(ncid, secs_id, 'units', 4, 'seconds')
iret = nf_put_att_text(ncid, elev_id, 'long_name', 16, 'tidal elevations')
!kbk call check_err(iret)
iret = nf_put_att_text(ncid, elev_id, 'units', 6, 'meters')
!kbk call check_err(iret)
realval(1) = -15
iret = nf_put_att_real(ncid, elev_id, 'valid_min', NF_REAL, 1, realval)
!kbk call check_err(iret)
realval(1) = 15
iret = nf_put_att_real(ncid, elev_id, 'valid_max', NF_REAL, 1, realval)
!kbk call check_err(iret)
realval(1) = -99
iret = nf_put_att_real(ncid, elev_id, 'missing_value', NF_REAL, 1,realval)
!kbk call check_err(iret)
iret = nf_enddef(ncid)
!kbk call check_err(iret)
return
end
program make_tides
use time, only: String2JulSecs
implicit none
include 'netcdf.inc'
integer :: yy1=-1,mm1=-1,dd1=-1
integer :: yy2=-1,mm2=-1,dd2=-1
character(len=128) :: fn
character(len=19) :: t1,t2
real(4), dimension(:), allocatable :: lons,lats
real(4), dimension(:), allocatable :: z
real(8) :: hh=0.d0
character(len=20) :: model='legi'
integer :: i,j,n,nmax
integer :: rc
integer :: ncid,time_id,jul_id,secs_id,elev_id
integer :: start(2), edges(2)
integer :: jul0,secs0
integer :: jul1,secs1
integer :: jul2,secs2
integer :: jd,ss,ia(1)
integer :: jnasa=13222 ! jnasa=0 --> 1958/01/01
character(len=19) :: t0 = '1958/01/01 00:00:00'
call String2JulSecs(t0,jul0,secs0)
!
write(0,*) 'Reading time info from tides.dates'
open(unit=10,file="tides.dates",status='old',err=120)
read(10,*) yy1,mm1,dd1
read(10,*) yy2,mm2,dd2
close(10)
write(t1,'(i4.4,a1,i2.2,a1,i2.2xa8)') yy1,'-',mm1,'-',dd1,'00:00:00'
write(t2,'(i4.4,a1,i2.2,a1,i2.2xa8)') yy2,'-',mm2,'-',dd2,'00:00:00'
call String2JulSecs(t1,jul1,secs1)
call String2JulSecs(t2,jul2,secs2)
jnasa = jul1 - jul0
nmax = (jul2-jul1)*24 + 1
write(0,*) t0,jul0,secs0
write(0,*) t1,jul1,secs1
write(0,*) t2,jul2,secs2
write(0,*) jnasa,nmax
jd = jul1
ss = secs1
write(0,*) 'Start: ',t1
write(0,*) 'Stop: ',t2
read(5,*) n
allocate(lons(n),stat=rc)
if (rc /= 0) stop 'make_tides: Error allocating memory (lons)'
allocate(lats(n),stat=rc)
if (rc /= 0) stop 'make_tides: Error allocating memory (lats)'
allocate(z(n),stat=rc)
if (rc /= 0) stop 'make_tides: Error allocating memory (z)'
do i=1,n
read(5,*) lats(i),lons(i)
end do
#undef NETCDF
#define NETCDF
#ifdef NETCDF
fn = 'bdy_2d.nc'
write(fn,100) 'tides.',yy1,'-',mm1,'-',dd1,'_',yy2,'-',mm2,'-',dd2,'.nc'
100 format (a6,i4.4,a1,i2.2,a1,i2.2,a1,i4.4,a1,i2.2,a1,i2.2,a3)
call create_nc_file(fn,n,t1,ncid,time_id,jul_id,secs_id,elev_id)
do j=1,nmax
z(1) = (j-1)*3600.
start(1) = j
edges(1) = 1
rc = nf_put_vara_real(ncid, time_id, start, edges, z(1))
ia(1) = jd
rc = nf_put_vara_int(ncid, jul_id, start, edges, ia)
ia(1) = ss
rc = nf_put_vara_int(ncid, secs_id, start, edges, ia)
ss = ss+3600
do i=1,n
call otide(model,z(i),lats(i),lons(i),jnasa,hh,rc)
if (z(i) .lt. 10000.) then
z(i) = 0.01*z(i)
else
z(i) = 0.00
end if
end do
start(1) = 1
start(2) = j
edges(1) = n
edges(2) = 1
rc = nf_put_vara_real(ncid, elev_id, start, edges, z)
hh=hh+1.d0
if( hh .gt. 23 ) then
jnasa = jnasa + 1
hh = 0.d0
jd = jd+1
ss = 0
end if
end do
rc = nf_close(ncid)
#else
do j=1,nmax
print *, (j-1)*3600.,' ,'
end do
do j=1,nmax
do i=1,n
call otide(model,z(i),lats(i),lons(i),jnasa,hh,rc)
if (z(i) .lt. 10000.) then
print *, z(i)/100.,' ,'
else
print *, -99.00,' ,'
end if
end do
! print *,jnasa, hh, z(1)
hh=hh+1.d0
if( hh .gt. 23 ) then
jnasa = jnasa + 1
hh = 0.d0
end if
end do
#endif
stop
120 write(0,*) 'Unable to open tides.dates'
stop 'make_tides'
end
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment