Dear all ,
Though I uses netcdf for a while now, I am new to this group.
Please help me if any one has answer to my below problem.
I am trying to build an Objective analysis package from HOPS OA system.
in a Redhat Enterprice Linux machine with 64bit. I have sucessfully
installed netcdf 3.6.2 on this and is working fine with all other
programs. But the OA pakage when it is made used netcdf 2.3.2 version.
in the bundle only 2 fortran codes uses netcdf properties which is
basically to write output as netcdf files. I am attaching here with those
2 files and the GNU make file. which I modified to suite my system
configuration.
When I compile the entire set of program I am getting errors related to
netcdf as below from the attached 2 fortran files. Please advice me if
there is any major change is commands used in older version of netcdf and
the new version of netcdf and where I need to make changes in the attached
programs.
Sudheer
g77 -u -O -o ./oag oagmain.o acor.o blkdat.o
brent.o caldate.o costfun.o dcostfun.o defcdf.o
descent.o dhlev.o diagn.o dynht.o errscl.o
f1dim.o filter.o gcircle.o getclima.o exitus.o
getdynht.o get_date.o get_ewpt.o getobs.o gregorian.o
headln.o length.o linmin.o lintrp.o ll2xy.o
lnblk.o locate.o lubksb.o ludcmp.o mapcor.o mnbrak.o
nxt_blnk.o oa_err.o oamean.o oamap.o oapar.o
qtrap.o readgrids.o readhydro.o rotparm.o rout_chk.o
set_type.o svafunc.o svan.o svel.o trapzd.o xclima.o
xhydro.o xy2ll.o -L/usr/local/lib -lnetcdf
defcdf.o(.text+0x72d0): In function `defcdf_':
: undefined reference to `ncvpt_'
defcdf.o(.text+0x7340): more undefined references to `ncvpt_' follow
defcdf.o(.text+0x73a8): In function `defcdf_':
: undefined reference to `for_write_seq_fmt'
defcdf.o(.text+0x7400): In function `defcdf_':
: undefined reference to `for_write_seq_fmt'
defcdf.o(.text+0x7458): In function `defcdf_':
: undefined reference to `for_write_seq_fmt'
defcdf.o(.text+0x74b9): In function `defcdf_':
: undefined reference to `for_write_seq_fmt'
defcdf.o(.text+0x751a): In function `defcdf_':
: undefined reference to `for_write_seq_fmt'
defcdf.o(.text+0x757b): more undefined references to `for_write_seq_fmt'
follow
defcdf.o(.text+0x75ac): In function `defcdf_':
: undefined reference to `ncvid_'
defcdf.o(.text+0x75d3): In function `defcdf_':
: undefined reference to `ncvpt1_'
defcdf.o(.text+0x75ee): In function `defcdf_':
: undefined reference to `ncvid_'
defcdf.o(.text+0x7615): In function `defcdf_':
: undefined reference to `ncvpt1_'
defcdf.o(.text+0x7638): In function `defcdf_':
: undefined reference to `for_cpystr'
defcdf.o(.text+0x76ca): In function `defcdf_':
: undefined reference to `ncaptc_'
defcdf.o(.text+0x76ed): In function `defcdf_':
: undefined reference to `for_cpystr'
defcdf.o(.text+0x777c): In function `defcdf_':
: undefined reference to `ncaptc_'
defcdf.o(.text+0x779f): In function `defcdf_':
: undefined reference to `for_cpystr'
defcdf.o(.text+0x782e): In function `defcdf_':
: undefined reference to `ncaptc_'
defcdf.o(.text+0x7865): In function `defcdf_':
: undefined reference to `ncvdef_'
defcdf.o(.text+0x7889): In function `defcdf_':
: undefined reference to `for_cpystr'
defcdf.o(.text+0x791a): In function `defcdf_':
: undefined reference to `ncaptc_'
defcdf.o(.text+0x7938): In function `defcdf_':
: undefined reference to `for_cpystr'
defcdf.o(.text+0x79c9): In function `defcdf_':
: undefined reference to `ncaptc_'
defcdf.o(.text+0x79f8): In function `defcdf_':
: undefined reference to `ncvdef_'
defcdf.o(.text+0x7a1c): In function `defcdf_':
: undefined reference to `for_cpystr'
defcdf.o(.text+0x7aad): In function `defcdf_':
: undefined reference to `ncaptc_'
defcdf.o(.text+0x7acb): In function `defcdf_':
: undefined reference to `for_cpystr'
defcdf.o(.text+0x7b5c): In function `defcdf_':
: undefined reference to `ncaptc_'
defcdf.o(.text+0x7b7a): In function `defcdf_':
: undefined reference to `for_cpystr'
defcdf.o(.text+0x7c0b): In function `defcdf_':
: undefined reference to `ncaptc_'
defcdf.o(.text+0x7c29): In function `defcdf_':
: undefined reference to `for_cpystr'
defcdf.o(.text+0x7cba): In function `defcdf_':
: undefined reference to `ncaptc_'
defcdf.o(.text+0x7cd8): In function `defcdf_':
: undefined reference to `for_cpystr'
defcdf.o(.text+0x7d69): In function `defcdf_':
: undefined reference to `ncaptc_'
defcdf.o(.text+0x7d8f): In function `defcdf_':
: undefined reference to `ncddef_'
defcdf.o(.text+0x7e1b): In function `defcdf_':
: undefined reference to `for_write_seq_fmt'
exitus.o(.text+0x2a): In function `exitus_':
: undefined reference to `ncclos_'
exitus.o(.text+0x52): In function `exitus_':
: undefined reference to `ncclos_'
readgrids.o(.text+0x16): In function `readgrids_':
: undefined reference to `ncpopt_'
readgrids.o(.text+0x79): In function `readgrids_':
: undefined reference to `ncopn_'
readgrids.o(.text+0x130): In function `readgrids_':
: undefined reference to `ncinq_'
readgrids.o(.text+0x1a6): In function `readgrids_':
: undefined reference to `ncdinq_'
readgrids.o(.text+0x595): In function `readgrids_':
: undefined reference to `ncvid_'
readgrids.o(.text+0x65f): In function `readgrids_':
: undefined reference to `ncvgt1_'
readgrids.o(.text+0x820): In function `readgrids_':
: undefined reference to `ncvid_'
readgrids.o(.text+0x8ea): In function `readgrids_':
: undefined reference to `ncvgt1_'
readgrids.o(.text+0xaa3): In function `readgrids_':
: undefined reference to `ncvid_'
readgrids.o(.text+0xb70): In function `readgrids_':
: undefined reference to `ncvgt1_'
readgrids.o(.text+0xd38): In function `readgrids_':
: undefined reference to `ncvid_'
readgrids.o(.text+0xe05): In function `readgrids_':
: undefined reference to `ncvgt1_'
readgrids.o(.text+0xebb): In function `readgrids_':
: undefined reference to `ncvid_'
readgrids.o(.text+0xf88): In function `readgrids_':
: undefined reference to `ncvgt1_'
readgrids.o(.text+0x103e): In function `readgrids_':
: undefined reference to `ncvid_'
readgrids.o(.text+0x110b): In function `readgrids_':
: undefined reference to `ncvgt1_'
readgrids.o(.text+0x1298): In function `readgrids_':
: undefined reference to `ncvid_'
readgrids.o(.text+0x12e2): In function `readgrids_':
: undefined reference to `ncvgt1_'
readgrids.o(.text+0x13a1): In function `readgrids_':
: undefined reference to `ncvid_'
readgrids.o(.text+0x13eb): In function `readgrids_':
: undefined reference to `ncvgt1_'
readgrids.o(.text+0x1918): In function `readgrids_':
: undefined reference to `ncvid_'
readgrids.o(.text+0x1981): In function `readgrids_':
: undefined reference to `ncvid_'
readgrids.o(.text+0x1a62): In function `readgrids_':
: undefined reference to `ncvgt_'
readgrids.o(.text+0x1b40): In function `readgrids_':
: undefined reference to `ncvid_'
readgrids.o(.text+0x1c24): In function `readgrids_':
: undefined reference to `ncvgt_'
readgrids.o(.text+0x1d0d): In function `readgrids_':
: undefined reference to `ncvgt_'
collect2: ld returned 1 exit status
gmake: *** [oag] Error 1
--
º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤º¤ø,¸¸,ø¤º
Dr. Sudheer Joseph
Scientist
Indian National Centre for Ocean Information Services (INCOIS)
Post Box No.21, IDA Jeedimetla P.O.
Hyderabad,Ranga Reddy District - 500 055
Andhra Pradesh, India.
TEl:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O)
E-mail:sjo@xxxxxxxxxxxxxx; callsjo@xxxxxxxxx; sjo@xxxxxxxxxxxxx.
Web- http://oppamthadathil.tripod.com
º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤º¤ø,¸¸,ø¤º
"The ultimate measure of a man is
not where he stands in moments of
comfort and convenience, but where
he stands at times of challenge and
controversy."
Martin Luther King, Jr.
subroutine readgrids
c
c=======================================================================
c ===
c This routines read some varaibles from GRIDS NetCDF file. ===
c ===
c=======================================================================
c
c-----------------------------------------------------------------------
c Define global data.
c-----------------------------------------------------------------------
c
#include <param.h>
#include <domdat.h>
#include <inppar.h>
#include <netcdf.inc>
#include <oagrid.h>
#include <oa_netcdf.h>
c
c-----------------------------------------------------------------------
c Define local data.
c-----------------------------------------------------------------------
c
integer dbgn,dend,dimid,dimsiz,dlen,fbgn,fend,flen,icoor,imax,
* jmax,n,ndims,ngatts,nvars,recdim,sbn,snd,sln,xindx,yindx
integer count(3),start(3)
logical old
real c0,c1,gdelx,gdely,gridx,gridy,m2km,rlatd,rlngd,scl,theta
character*5 ustr
character*256 dimnam
parameter (c0=0.0,c1=1.0,m2km=0.001,xindx=1,yindx=2)
c
c=======================================================================
c Begin executable code.
c=======================================================================
c
c Open GRIDS NetCDF file.
c
call ncpopt(ncverbos)
call length (fname(5),flen,fbgn,fend)
ncgrdid=ncopn(fname(5)(fbgn:fend),ncnowrit,rcode)
if(rcode.ne.0) then
write(iprt,900) fname(5)(fbgn:fend)
call exitus('READGRIDS')
endif
c
c-----------------------------------------------------------------------
c Inquire about the contents of open NetCDF file: Inquire about the
c dimensions and variables.
c-----------------------------------------------------------------------
c
call ncinq(ncgrdid,ndims,nvars,ngatts,recdim,rcode)
if(rcode.eq.0) then
c
c Inquire about dimensions.
c
do 10 n=1,ndims
dimid=n
call ncdinq(ncgrdid,dimid,dimnam,dimsiz,rcode)
if(rcode.ne.0) then
write(iprt,910) n,fname(5)(fbgn:fend)
call exitus('READGRIDS')
endif
call length (dimnam,dlen,dbgn,dend)
if((dimnam(dbgn:dend).eq.'lon').or.
* (dimnam(dbgn:dend).eq.'tlon')) then
imax=dimsiz
elseif((dimnam(dbgn:dend).eq.'lat').or.
* (dimnam(dbgn:dend).eq.'tlat')) then
jmax=dimsiz
endif
10 continue
c
c Check main dimensions.
c
if(imax.ne.im) then
write(iprt,950) 'IM = ',im,imax
im=imax
imjm=im*jm
endif
if(jmax.ne.jm) then
write(iprt,950) 'JM = ',jm,jmax
jm=jmax
imjm=im*jm
endif
if (imjm.gt.mgrd) then
write(iprt,920) mgrd,imjm
call exitus ('READGRIDS')
endif
c
else
write(iprt,930) fname(5)(fbgn:fend)
call exitus('READGRIDS')
endif
c
c-----------------------------------------------------------------------
c Read in and check some geometry parameters.
c-----------------------------------------------------------------------
c
c Coordinate type.
c
varid = ncvid (ncgrdid,'coord',rcode)
if (rcode.ne.0) then
write(iprt,960) 'coord',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
call ncvgt1 (ncgrdid,varid,1,icoor,rcode)
if (rcode.ne.0) then
write(iprt,970) 'coord',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
if (coord.ne.icoor) then
write(iprt,950) 'COORD = ',coord,icoor
coord=icoor
end if
c
if (coord.eq.0) then
scl = m2km
ustr = '(km)'
else
scl = c1
ustr = '(deg)'
end if
call length (ustr,sln,sbn,snd)
c
c Grid spacing.
c
varid = ncvid (ncgrdid,'meandx',rcode)
if (rcode.ne.0) then
write(iprt,960) 'meandx',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
call ncvgt1 (ncgrdid,varid,1,gridx,rcode)
if (rcode.ne.0) then
write(iprt,970) 'meandx',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
gridx = gridx*scl
if (gridx.ne.dx) then
write(iprt,940) 'DX = ',dx,ustr(sbn:snd),gridx,ustr(sbn:snd)
dx=gridx
end if
c
varid = ncvid (ncgrdid,'meandy',rcode)
if (rcode.ne.0) then
write(iprt,960) 'meandy',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
call ncvgt1 (ncgrdid,varid,1,gridy,rcode)
if (rcode.ne.0) then
write(iprt,970) 'meandy',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
gridy = gridy*scl
if (gridy.ne.dy) then
write(iprt,940) 'DY = ',dy,ustr(sbn:snd),gridy,ustr(sbn:snd)
dy=gridy
end if
c
c Transformation centroid.
c
varid = ncvid (ncgrdid,'rlngd',rcode)
if (rcode.ne.0) then
write(iprt,960) 'rlngd',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
call ncvgt1 (ncgrdid,varid,1,rlngd,rcode)
if (rcode.ne.0) then
write(iprt,970) 'rlngd',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
c
varid = ncvid (ncgrdid,'rlatd',rcode)
if (rcode.ne.0) then
write(iprt,960) 'rlatd',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
call ncvgt1 (ncgrdid,varid,1,rlatd,rcode)
if (rcode.ne.0) then
write(iprt,970) 'rlatd',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
c
c Grid rotation.
c
varid = ncvid (ncgrdid,'thetad',rcode)
if (rcode.ne.0) then
write(iprt,960) 'thetad',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
call ncvgt1 (ncgrdid,varid,1,theta,rcode)
if (rcode.ne.0) then
write(iprt,970) 'thetad',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
if (theta.ne.thetad) then
write(iprt,940) 'THETAD = ',thetad,'(deg)',theta,'(deg)'
thetad=theta
end if
c
c Grid offset.
c
old = .false.
c
varid = ncvid (ncgrdid,'delx',rcode)
if (rcode.eq.0) then
call ncvgt1 (ncgrdid,varid,1,gdelx,rcode)
if (rcode.ne.0) then
write(iprt,970) 'delx',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
else
old = .true.
end if
c
varid = ncvid (ncgrdid,'dely',rcode)
if (rcode.eq.0) then
call ncvgt1 (ncgrdid,varid,1,gdely,rcode)
if (rcode.ne.0) then
write(iprt,970) 'dely',fname(5)(fbgn:fend)
call exitus ('READGRIDS')
end if
else
old = .true.
end if
c
c Preserve backward compatibility.
c
if (old) then
if (coord.ne.1) then
gdelx=c0
gdely=c0
write(iprt,980)
else
gdelx=rlngd
gdely=rlatd
rlngd=c0
rlatd=c0
write(iprt,990) rlngd,rlatd
end if
end if
c
c Check backwardly compatibility CLATD, CLNGD, DELX and DELY.
c
if (rlatd.ne.clatd) then
write(iprt,940) 'CLATD = ',clatd,'(deg)',rlatd,'(deg)'
clatd=rlatd
end if
c
if (rlngd.ne.clngd) then
write(iprt,940) 'CLNGD = ',clngd,'(deg)',rlngd,'(deg)'
clngd=rlngd
endif
c
gdelx = gdelx*scl
if (gdelx.ne.delx) then
write(iprt,940) 'DELX = ',delx,ustr(sbn:snd),gdelx,ustr(sbn:snd)
delx=gdelx
end if
c
gdely = gdely*scl
if (gdely.ne.dely) then
write(iprt,940) 'DELY = ',dely,ustr(sbn:snd),gdely,ustr(sbn:snd)
dely=gdely
end if
c
c Land Mask.
c
varid = ncvid (ncgrdid,'landt',rcode)
lmsk = rcode .eq. 0
c
c-----------------------------------------------------------------------
c Read in Land/Sea mask data.
c-----------------------------------------------------------------------
c
if(lmsk) then
start(1)=1
count(1)=imax
start(2)=1
count(2)=jmax
varid=ncvid(ncgrdid,'landt',rcode)
if(rcode.ne.0) then
write(iprt,960) 'landt',fname(5)(fbgn:fend)
call exitus('READGRIDS')
endif
call ncvgt(ncgrdid,varid,start,count,landt,rcode)
if(rcode.ne.0) then
write(iprt,970) 'landt',fname(5)(fbgn:fend)
call exitus('READGRIDS')
endif
endif
c
c-----------------------------------------------------------------------
c Read in longitude and latitude data for each grid point.
c-----------------------------------------------------------------------
c
start(1)= xindx
count(1)=1
start(2)=1
count(2)=imax
start(3)=1
count(3)=jmax
varid=ncvid(ncgrdid,'tgrid2',rcode)
if(rcode.ne.0) then
write(iprt,960) 'tgrid2',fname(5)(fbgn:fend)
call exitus('READGRIDS')
endif
call ncvgt(ncgrdid,varid,start,count,lon,rcode)
if(rcode.ne.0) then
write(iprt,970) 'tgrid2 x-index',fname(5)(fbgn:fend)
call exitus('READGRIDS')
endif
start(1)= yindx
count(1)=1
call ncvgt(ncgrdid,varid,start,count,lat,rcode)
if(rcode.ne.0) then
write(iprt,970) 'tgrid2 y-index',fname(5)(fbgn:fend)
call exitus('READGRIDS')
endif
c
900 format(/'READGRIDS - unable to open GRIDS NetCDF file: ',a)
910 format(/' READGRIDS - error while reading dimension: ',1h",a,1h"/
* 13x,'in GRIDS NetCDF file: ',1h",a,1h")
920 format(' READGRIDS: underdimensioned arrays, MGRD, IMJM = ',i5,1x
& ,i5/12x,'change file ',1h",'param.h',1h",' and recompile'/)
930 format(/' READGRIDS - unable to inquire about contents of'/13x,
* 'GRIDS NetCDF file: ',1h",a,1h")
940 format(/' READGRIDS - WARNING: inconsistent parameter value, ',
* 1h",a,1h",g15.8,1x,a/32x,'replaced with GRIDS value = ',
* g15.8,1x,a)
950 format(/' READGRIDS - WARNING: inconsistent parameter value, ',
* 1h",a,1h",i10/32x,'replaced with GRIDS value = ',i10)
960 format(/' READGRIDS - cannot find variable: ',1h",a,1h"/13x,
* 'in GRIDS NetCDF file: ',1h",a,1h")
970 format(/' READGRIDS - error while reading variable: ',1h",a,1h"/
* 13x,'in GRIDS NetCDF file: ',1h",a,1h")
980 format(/' READGRIDS - WARNING: old GRIDS file.'/13x,
* 'Replacing GRIDS values (DELX,DELY) by (0,0)')
990 format(/' READGRIDS - WARNING: old GRIDS file.'/13x,'Replacing ',
* 'GRIDS values (DELX,DELY) by (',f8.3,', ',f8.3,')'/13x,
* 'and GRIDS values (CLNGD,CLATD) by (0,0)')
return
end
subroutine defcdf
c
c=======================================================================
c ===
c This routine defines output NetCDF file. ===
c ===
c Calls: ===
c ===
c NCAPT, NCAPTC, NCCRE, NCDDEF, NCENDF, NCPOPT, NCVDEF, NCVID, ===
c NCVPT, NCVPT1 (NetCDF library) ===
c EXITUS, GET_DATE, LNBLK ===
c ===
c=======================================================================
c
c-----------------------------------------------------------------------
c Define global data.
c-----------------------------------------------------------------------
c
#include <param.h>
#include <clima.h>
#include <corscl.h>
#include <domdat.h>
#include <hydobs.h>
#include <inppar.h>
#include <netcdf.inc>
#include <oagrid.h>
#include <oa_netcdf.h>
#include <obscor.h>
#include <version.h>
c
c-----------------------------------------------------------------------
c Define local data.
c-----------------------------------------------------------------------
c
integer ax2dim,ax3dim,dbgn,dend,g2did,g3did,latdim,ldate,levdim,
* lmod,londim,lvnum,m,mbgn,mend,mskid,n,sbgn,send,slen,
* timdim,vartyp,vbgn,vend,xindx,yindx,zindx
integer count(3),fdim(4),fdim2(2),start(3)
real c0,c1,jul_off,km2m,scl,spv
real wrk(mlev)
character*44 date_str
character*120 history
character*256 wkstr
parameter (c0=0.0,c1=1.0,jul_off=2440000.0,km2m=1000.0,
* spv=1.0e+35,xindx=1,yindx=2,zindx=3)
c
c=======================================================================
c Begin executable code.
c=======================================================================
c
c Create netCDF file.
c
call ncpopt(ncverbos)
call length (fname(1),slen,sbgn,send)
ncoutid=nccre(fname(1)(sbgn:send),ncclob,rcode)
if(rcode.ne.0) then
write(iprt,900) fname(1)(sbgn:send)
call exitus('DEFCDF')
endif
c
c Create history attribute label.
c
call get_date(date_str)
call length (date_str,ldate,dbgn,dend)
call length (model,lmod,mbgn,mend)
call length (vnum,lvnum,vbgn,vend)
if(ldate.gt.0) then
history=model(mbgn:mend)//', Version '//vnum(vbgn:vend)//', '
& //date_str(dbgn:dend)
else
history=model(mbgn:mend)//', Version '//vnum(vbgn:vend)
endif
c
c Define netCDF dimensions.
c
londim=ncddef(ncoutid,'lon',im,rcode)
latdim=ncddef(ncoutid,'lat',jm,rcode)
levdim=ncddef(ncoutid,'level',nlev,rcode)
timdim=ncddef(ncoutid,'time',ncunlim,rcode)
if(lmsk) ax2dim=ncddef(ncoutid,'axis2',2,rcode)
ax3dim=ncddef(ncoutid,'axis3',3,rcode)
c
c Set single or double precision.
c
vartyp=ncfloat
c vartyp=ncdouble
c
c Define global title.
c
call length (title,slen,sbgn,send)
call ncaptc (ncoutid,ncglobal,'title',ncchar,slen,
* title(sbgn:send),rcode)
call length (fname(1),slen,sbgn,send)
call ncaptc (ncoutid,ncglobal,'out_file',ncchar,slen,
* fname(1)(sbgn:send),rcode)
call length (fname(3),slen,sbgn,send)
call ncaptc (ncoutid,ncglobal,'hyd_file',ncchar,slen,
* fname(3)(sbgn:send),rcode)
if((iclima.eq.1).or.(iclima.eq.2)) then
call length (fname(4),slen,sbgn,send)
call ncaptc (ncoutid,ncglobal,'clm_file',ncchar,slen,
* fname(4)(sbgn:send),rcode)
endif
if(igrids.ne.0) then
call length (fname(5),slen,sbgn,send)
call ncaptc (ncoutid,ncglobal,'grd_file',ncchar,slen,
* fname(5)(sbgn:send),rcode)
endif
call ncaptc (ncoutid,ncglobal,'type',ncchar,lmod,model(mbgn:mend),
* rcode)
call ncaptc (ncoutid,ncglobal,'version',ncchar,lvnum,
* vnum(vbgn:vend),rcode)
call length (history,slen,sbgn,send)
call ncaptc (ncoutid,ncglobal,'history',ncchar,slen,
* history(sbgn:send),rcode)
c
c-----------------------------------------------------------------------
c Define parameters.
c-----------------------------------------------------------------------
c
c Observations and climatology input format type.
c
varid = ncvdef (ncoutid,'ihfrmt',nclong,0,0,rcode)
wkstr = 'input format type for hydrographic data'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - z, T, S, Dyn H'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_0',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - z, T, S'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_1',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - z, T'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_2',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - z, Dyn H'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_3',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - z, any oceanic field'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_4',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - any field (a single value)'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_5',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'formatted - HOPS hydrography format'
call length (wkstr,slen,sbgn,send)
call ncaptc(ncoutid,varid,'option_6',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
if((iclima.eq.1).or.(iclima.eq.2)) then
varid = ncvdef (ncoutid,'icfrmt',nclong,0,0,rcode)
wkstr = 'input format type for climatology data'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - z, T, S, Dyn H'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_0',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - z, T, S'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_1',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - z, T'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_2',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - z, Dyn H'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_3',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - z, any oceanic field'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_4',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unformatted - any field (a single value)'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_5',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'formatted - HOPS hydrography format'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_6',ncchar,slen,
* wkstr(sbgn:send),rcode)
endif
c
c Mean field computation switch.
c
varid = ncvdef (ncoutid,'iclima',nclong,0,0,rcode)
wkstr = 'mean field computation switch'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'use only hydrography observations'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_0',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'use only climatology observations'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_1',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'use both hydrography and climatology observations'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_2',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'use global hydrography mean (a single value)'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_3',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c OA coordinates type.
c
varid = ncvdef (ncoutid,'coord',nclong,0,0,rcode)
wkstr = 'OA computation coordinates switch'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'Cartesian'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_0',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'unrotated spherical'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_1',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'rotated spherical'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_2',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Geometry parameters.
c
varid = ncvdef (ncoutid,'dx',vartyp,0,0,rcode)
wkstr = 'zonal grid spacing'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
if(coord.eq.0) then
wkstr = 'meter'
elseif((coord.eq.1).or.(coord.eq.2)) then
wkstr = 'degrees'
endif
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,wkstr(sbgn:send),
& rcode)
c
varid = ncvdef (ncoutid,'dy',vartyp,0,0,rcode)
wkstr = 'meridional grid spacing'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
if(coord.eq.0) then
wkstr = 'meter'
elseif((coord.eq.1).or.(coord.eq.2)) then
wkstr = 'degrees'
endif
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,wkstr(sbgn:send),
& rcode)
c
varid = ncvdef (ncoutid,'rlngd',vartyp,0,0,rcode)
wkstr = 'Transformation centroid longitude'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'degrees_east'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,wkstr(sbgn:send),
& rcode)
c
varid = ncvdef (ncoutid,'rlatd',vartyp,0,0,rcode)
wkstr = 'Transformation centroid latitude'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'degrees_north'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,wkstr(sbgn:send),
& rcode)
c
varid = ncvdef (ncoutid,'delx',vartyp,0,0,rcode)
wkstr = 'Longitudinal offset from transformation point to grid '//
& 'center'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
if(coord.eq.0) then
wkstr = 'meter'
elseif((coord.eq.1).or.(coord.eq.2)) then
wkstr = 'degrees'
endif
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,wkstr(sbgn:send),
& rcode)
c
varid = ncvdef (ncoutid,'dely',vartyp,0,0,rcode)
wkstr = 'Latitudinal offset from transformation point to grid '//
& 'center'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
if(coord.eq.0) then
wkstr = 'meter'
elseif((coord.eq.1).or.(coord.eq.2)) then
wkstr = 'degrees'
endif
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,wkstr(sbgn:send),
& rcode)
c
varid = ncvdef (ncoutid,'thetad',vartyp,0,0,rcode)
wkstr = 'domain rotation angle'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'degrees'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Influential observations parameters.
c
varid = ncvdef (ncoutid,'nnce',nclong,0,0,rcode)
wkstr = 'number of influential observations'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'rnce',vartyp,0,0,rcode)
wkstr = 'radius of influence'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'tnce',vartyp,0,0,rcode)
wkstr = 'influence time window'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'day'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Averaging radius and time window.
c
varid = ncvdef (ncoutid,'ravg',vartyp,0,0,rcode)
wkstr = 'averaging radius'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'tavg',vartyp,0,0,rcode)
wkstr = 'averaging time window'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'day'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Outlier radius.
c
varid = ncvdef (ncoutid,'rout',vartyp,0,0,rcode)
wkstr = 'radius for outlier observations'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Analytical correlation type.
c
varid = ncvdef (ncoutid,'icorr',nclong,0,0,rcode)
wkstr = 'analytical correlation type'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'Gaussian in space and time'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_1',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Zero-crossing correlation scales for estimate and mean fields.
c
varid = ncvdef (ncoutid,'xzero',vartyp,0,0,rcode)
wkstr = 'estimate, zonal zero-crossing for correlation'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'yzero',vartyp,0,0,rcode)
wkstr = 'estimate, meridional zero-crossing for correlation'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'xzerom',vartyp,0,0,rcode)
wkstr = 'mean, zonal zero-crossing for correlation'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'yzerom',vartyp,0,0,rcode)
wkstr = 'mean, meridional zero-crossing for correlation'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Spatial decorrelation scales for estimate and mean fields.
c
varid = ncvdef (ncoutid,'xdcay',vartyp,0,0,rcode)
wkstr = 'estimate, zonal decorrelation scale'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'ydcay',vartyp,0,0,rcode)
wkstr = 'estimate, meridional decorrelation scale'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'xdcaym',vartyp,0,0,rcode)
wkstr = 'mean, zonal decorrelation scale'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'ydcaym',vartyp,0,0,rcode)
wkstr = 'mean, meridional decorrelation scale'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Temporal decorrelation scale for estimate and mean fields.
c
varid = ncvdef (ncoutid,'tdcay',vartyp,0,0,rcode)
wkstr = 'temporal decorrelation scale'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'day'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'tdcaym',vartyp,0,0,rcode)
wkstr = 'mean, temporal decorrelation scale'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'day'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Correlation phase speed and rotation angle for estimate and mean fields.
c
varid = ncvdef (ncoutid,'uphse',vartyp,0,0,rcode)
wkstr = 'correlation, zonal phase speed'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter day-1'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'vphse',vartyp,0,0,rcode)
wkstr = 'correlation, meridional phase speed'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter day-1'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'corang',vartyp,0,0,rcode)
wkstr = 'correlation, rotation angle'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'degrees, counterclockwise from EAST'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'uphsem',vartyp,0,0,rcode)
wkstr = 'mean, correlation, zonal phase speed'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter day-1'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'vphsem',vartyp,0,0,rcode)
wkstr = 'mean, correlation, meridional phase speed'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter day-1'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'corangm',vartyp,0,0,rcode)
wkstr = 'mean, correlation, rotation angle'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'degrees, counterclockwise from EAST'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Observations and climatology noise variance.
c
varid = ncvdef (ncoutid,'obserr',vartyp,0,0,rcode)
wkstr = 'observation noise variance'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'clmerr',vartyp,0,0,rcode)
wkstr = 'climatology noise variance'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Detrend option.
c
varid = ncvdef (ncoutid,'itrt',nclong,0,0,rcode)
wkstr = 'degree of polynomial surface to remove'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'mean'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_0',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'linear'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_1',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'quadratic'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_2',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'cubic'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_3',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Shapiro filter order and number of applications.
c
varid = ncvdef (ncoutid,'nord',nclong,0,0,rcode)
wkstr = 'order of Shapiro filter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'nfrq',nclong,0,0,rcode)
wkstr = 'number of Shapiro filter applications'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
c Parameters used in computation of dynamic height.
c
if(ldynht) then
varid = ncvdef (ncoutid,'zref',vartyp,0,0,rcode)
wkstr = 'level of no motion'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
c
varid = ncvdef (ncoutid,'idhopt',nclong,0,0,rcode)
wkstr = 'specific volume integration option'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'ZREF to surface'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_1',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'ZREF to bottom'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_2',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'ZREF to surface and ZREF to bottom'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_3',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'surface to local bottom'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'option_4',ncchar,slen,
* wkstr(sbgn:send),rcode)
endif
c
c-----------------------------------------------------------------------
c Define geometry variables and their attributes.
c-----------------------------------------------------------------------
c
c Define depths at the middle of the vertical boxes.
c
fdim(1)=ax3dim
fdim(2)=levdim
varid = ncvdef (ncoutid,'zout',vartyp,2,fdim,rcode)
wkstr = 'depths at center of the grid vertical boxes'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,varid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
call ncapt (ncoutid,varid,'_FillValue',vartyp,1,spv,rcode)
c
c Define 2D grid positions. These fields are used in the vizualization
c modules.
c
if(lmsk) then
fdim(1)=ax2dim
fdim(2)=londim
fdim(3)=latdim
g2did = ncvdef (ncoutid,'grid2',vartyp,3,fdim,rcode)
wkstr = '2D grid positions'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,g2did,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = '1: longitude, 2: latitude'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,g2did,'axis',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'degrees_east, degrees_north'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,g2did,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
call ncapt (ncoutid,g2did,'_FillValue',vartyp,1,spv,rcode)
endif
c
c Define 3D grid positions. These fields are used in the vizualization
c modules.
c
fdim(1)=ax3dim
fdim(2)=londim
fdim(3)=latdim
g3did = ncvdef (ncoutid,'grid3',vartyp,3,fdim,rcode)
wkstr = '3D grid positions'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,g3did,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = '1: longitude, 2: latitude, 3: depth'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,g3did,'axis',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'degrees_east, degrees_north, meter'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,g3did,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
call ncapt (ncoutid,g3did,'_FillValue',vartyp,1,spv,rcode)
c
c Define Land/Sea mask data.
c
if(lmsk) then
fdim(1)=londim
fdim(2)=latdim
mskid = ncvdef (ncoutid,'mask',nclong,2,fdim,rcode)
wkstr = 'land/sea mask'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,mskid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'land'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,mskid,'option_0',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'sea'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,mskid,'option_1',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'mask, scalar'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,mskid,'field',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'grid2'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,mskid,'positions',ncchar,slen,
* wkstr(sbgn:send),rcode)
call ncapt (ncoutid,mskid,'_FillValue',nclong,1,-1,rcode)
endif
c
c-----------------------------------------------------------------------
c Define output variables and their attributes in the netCDF file.
c-----------------------------------------------------------------------
c
fdim(1)=levdim
fdim(2)=londim
fdim(3)=latdim
fdim(4)=timdim
c
fdim2(1)=levdim
fdim2(2)=timdim
c
c Time variable.
c
timeid = ncvdef (ncoutid,'time',vartyp,1,timdim,rcode)
wkstr = 'estimate time'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,timeid,'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'modified Julian day'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,timeid,'units',ncchar,slen,
* wkstr(sbgn:send),rcode)
call ncapt (ncoutid,timeid,'add_offset',vartyp,1,jul_off,rcode)
c
c Output variables.
c
do 10 n=1,nfld
m=idfld(n)
c
c Field estimate.
c
call length (fldnam(1,m),slen,sbgn,send)
ncfldid(n) = ncvdef (ncoutid,fldnam(1,m)(sbgn:send),vartyp,4,
* fdim,rcode)
call length (fldnam(2,m),slen,sbgn,send)
call ncaptc (ncoutid,ncfldid(n),'long_name',ncchar,slen,
* fldnam(2,m)(sbgn:send),rcode)
call length (fldnam(3,m),slen,sbgn,send)
call ncaptc (ncoutid,ncfldid(n),'units',ncchar,slen,
* fldnam(3,m)(sbgn:send),rcode)
call length (fldnam(4,m),slen,sbgn,send)
wkstr = fldnam(4,m)(sbgn:send)//', series'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncfldid(n),'field',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'grid3, product; zout, product'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncfldid(n),'positions',ncchar,slen,
* wkstr(sbgn:send),rcode)
if(lmsk) then
wkstr = 'mask'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncfldid(n),'mask',ncchar,slen,
* wkstr(sbgn:send),rcode)
endif
call ncapt (ncoutid,ncfldid(n),'missing_value',vartyp,1,spv,
* rcode)
call ncapt (ncoutid,ncfldid(n),'_FillValue',vartyp,1,spv,rcode)
c
c Error field.
c
call length (fldnam(1,m),slen,sbgn,send)
wkstr = fldnam(1,m)(sbgn:send)//'err'
call length (wkstr,slen,sbgn,send)
ncerrid(n) = ncvdef (ncoutid,wkstr(sbgn:send),vartyp,4,
* fdim,rcode)
call length (fldnam(2,m),slen,sbgn,send)
wkstr = 'observation error, '//fldnam(2,m)(sbgn:send)
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncerrid(n),'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
call length (fldnam(3,m),slen,sbgn,send)
call ncaptc(ncoutid,ncerrid(n),'units',ncchar,slen,
* fldnam(3,m)(sbgn:send),rcode)
call length (fldnam(4,m),slen,sbgn,send)
wkstr = 'error '//fldnam(4,m)(sbgn:send)//', series'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncerrid(n),'field',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'grid3, product; zout, product'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncerrid(n),'positions',ncchar,slen,
* wkstr(sbgn:send),rcode)
if(lmsk) then
wkstr = 'mask'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncerrid(n),'mask',ncchar,slen,
* wkstr(sbgn:send),rcode)
endif
call ncapt (ncoutid,ncerrid(n),'missing_value',vartyp,1,spv,
* rcode)
call ncapt (ncoutid,ncerrid(n),'_FillValue',vartyp,1,spv,rcode)
c
c RMS deviation field.
c
call length (fldnam(1,m),slen,sbgn,send)
wkstr = fldnam(1,m)(sbgn:send)//'rmsdev'
call length (wkstr,slen,sbgn,send)
ncrmsid(n) = ncvdef (ncoutid,wkstr(sbgn:send),vartyp,2,
* fdim2,rcode)
call length (fldnam(2,m),slen,sbgn,send)
wkstr = 'RMS deviation from mean, '//fldnam(2,m)(sbgn:send)
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncrmsid(n),'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
call length (fldnam(3,m),slen,sbgn,send)
call ncaptc(ncoutid,ncrmsid(n),'units',ncchar,slen,
* fldnam(3,m)(sbgn:send),rcode)
call length (fldnam(4,m),slen,sbgn,send)
wkstr = 'RMS '//fldnam(4,m)(sbgn:send)//', series'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncrmsid(n),'field',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'zout'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncrmsid(n),'positions',ncchar,slen,
* wkstr(sbgn:send),rcode)
call ncapt (ncoutid,ncrmsid(n),'missing_value',vartyp,1,spv,
* rcode)
call ncapt (ncoutid,ncrmsid(n),'_FillValue',vartyp,1,spv,rcode)
c
c Mean field.
c
call length (fldnam(1,m),slen,sbgn,send)
wkstr = fldnam(1,m)(sbgn:send)//'mean'
call length (wkstr,slen,sbgn,send)
ncavgid(n) = ncvdef (ncoutid,wkstr(sbgn:send),vartyp,4,fdim,
* rcode)
call length (fldnam(2,m),slen,sbgn,send)
wkstr = 'mean, '//fldnam(2,m)(sbgn:send)
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncavgid(n),'long_name',ncchar,slen,
* wkstr(sbgn:send),rcode)
call length (fldnam(3,m),slen,sbgn,send)
call ncaptc (ncoutid,ncavgid(n),'units',ncchar,slen,
* fldnam(3,m)(sbgn:send),rcode)
call length (fldnam(4,m),slen,sbgn,send)
wkstr = 'mean '//fldnam(4,m)(sbgn:send)//', series'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncavgid(n),'field',ncchar,slen,
* wkstr(sbgn:send),rcode)
wkstr = 'grid3, product; zout, product'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncavgid(n),'positions',ncchar,slen,
* wkstr(sbgn:send),rcode)
if(lmsk) then
wkstr = 'mask'
call length (wkstr,slen,sbgn,send)
call ncaptc (ncoutid,ncavgid(n),'mask',ncchar,slen,
* wkstr(sbgn:send),rcode)
endif
call ncapt (ncoutid,ncavgid(n),'missing_value',vartyp,1,spv,
* rcode)
call ncapt (ncoutid,ncavgid(n),'_FillValue',vartyp,1,spv,rcode)
10 continue
c
c=======================================================================
c Leave definition mode.
c=======================================================================
c
call ncendf(ncoutid,rcode)
c
c=======================================================================
c Write out parameters into netCDF file.
c=======================================================================
c
c Observations and climatology input format type.
c
varid=ncvid(ncoutid,'ihfrmt',rcode)
call ncvpt1(ncoutid,varid,1,ihfrmt,rcode)
if((iclima.eq.1).or.(iclima.eq.2)) then
varid=ncvid(ncoutid,'icfrmt',rcode)
call ncvpt1(ncoutid,varid,1,icfrmt,rcode)
endif
c
c Mean field computation switch.
c
varid=ncvid(ncoutid,'iclima',rcode)
call ncvpt1(ncoutid,varid,1,iclima,rcode)
c
c OA coordinates type.
c
varid=ncvid(ncoutid,'coord',rcode)
call ncvpt1(ncoutid,varid,1,coord,rcode)
c
if(coord.eq.0) then
scl=km2m
else
scl=c1
endif
c
c Geometry parameters.
c
varid=ncvid(ncoutid,'dx',rcode)
call ncvpt1(ncoutid,varid,1,dx*scl,rcode)
varid=ncvid(ncoutid,'dy',rcode)
call ncvpt1(ncoutid,varid,1,dy*scl,rcode)
varid=ncvid(ncoutid,'rlngd',rcode)
call ncvpt1(ncoutid,varid,1,clngd,rcode)
varid=ncvid(ncoutid,'rlatd',rcode)
call ncvpt1(ncoutid,varid,1,clatd,rcode)
varid=ncvid(ncoutid,'delx',rcode)
call ncvpt1(ncoutid,varid,1,delx*scl,rcode)
varid=ncvid(ncoutid,'dely',rcode)
call ncvpt1(ncoutid,varid,1,dely*scl,rcode)
varid=ncvid(ncoutid,'thetad',rcode)
call ncvpt1(ncoutid,varid,1,thetad,rcode)
c
c Influential observations parameters.
c
varid=ncvid(ncoutid,'nnce',rcode)
call ncvpt1(ncoutid,varid,1,nnce,rcode)
varid=ncvid(ncoutid,'rnce',rcode)
call ncvpt1(ncoutid,varid,1,rnce*km2m,rcode)
varid=ncvid(ncoutid,'tnce',rcode)
call ncvpt1(ncoutid,varid,1,tnce,rcode)
c
c Averaging radius and time window.
c
varid=ncvid(ncoutid,'ravg',rcode)
call ncvpt1(ncoutid,varid,1,ravg*km2m,rcode)
varid=ncvid(ncoutid,'tavg',rcode)
call ncvpt1(ncoutid,varid,1,tavg,rcode)
c
c Outlier radius.
c
varid=ncvid(ncoutid,'rout',rcode)
call ncvpt1(ncoutid,varid,1,rout*km2m,rcode)
c
c Analytical correlation type.
c
varid=ncvid(ncoutid,'icorr',rcode)
call ncvpt1(ncoutid,varid,1,icorr,rcode)
c
c Zero-crossing correlation scales for estimate and mean fields.
c
varid=ncvid(ncoutid,'xzero',rcode)
call ncvpt1(ncoutid,varid,1,xzero*km2m,rcode)
varid=ncvid(ncoutid,'yzero',rcode)
call ncvpt1(ncoutid,varid,1,yzero*km2m,rcode)
varid=ncvid(ncoutid,'xzerom',rcode)
call ncvpt1(ncoutid,varid,1,xzerom*km2m,rcode)
varid=ncvid(ncoutid,'yzerom',rcode)
call ncvpt1(ncoutid,varid,1,yzerom*km2m,rcode)
c
c Spatial decorrelation scales for estimate and mean fields.
c
varid=ncvid(ncoutid,'xdcay',rcode)
call ncvpt1(ncoutid,varid,1,xdcay*km2m,rcode)
varid=ncvid(ncoutid,'ydcay',rcode)
call ncvpt1(ncoutid,varid,1,ydcay*km2m,rcode)
varid=ncvid(ncoutid,'xdcaym',rcode)
call ncvpt1(ncoutid,varid,1,xdcaym*km2m,rcode)
varid=ncvid(ncoutid,'ydcaym',rcode)
call ncvpt1(ncoutid,varid,1,ydcaym*km2m,rcode)
c
c Temporal decorrelation scales for estimate and mean fields.
c
varid=ncvid(ncoutid,'tdcay',rcode)
call ncvpt1(ncoutid,varid,1,tdcay,rcode)
varid=ncvid(ncoutid,'tdcaym',rcode)
call ncvpt1(ncoutid,varid,1,tdcaym,rcode)
c
c Correlation phase speeds and rotation angles for estimate and mean fields.
c
varid=ncvid(ncoutid,'uphse',rcode)
call ncvpt1(ncoutid,varid,1,uphse*km2m,rcode)
varid=ncvid(ncoutid,'vphse',rcode)
call ncvpt1(ncoutid,varid,1,vphse*km2m,rcode)
varid=ncvid(ncoutid,'corang',rcode)
call ncvpt1(ncoutid,varid,1,corang,rcode)
varid=ncvid(ncoutid,'uphsem',rcode)
call ncvpt1(ncoutid,varid,1,uphsem*km2m,rcode)
varid=ncvid(ncoutid,'vphsem',rcode)
call ncvpt1(ncoutid,varid,1,vphsem*km2m,rcode)
varid=ncvid(ncoutid,'corangm',rcode)
call ncvpt1(ncoutid,varid,1,corangm,rcode)
c
c Observations and climatology noise vairance.
c
varid=ncvid(ncoutid,'obserr',rcode)
call ncvpt1(ncoutid,varid,1,obserr,rcode)
varid=ncvid(ncoutid,'clmerr',rcode)
call ncvpt1(ncoutid,varid,1,clmerr,rcode)
c
c Detrend option.
c
varid=ncvid(ncoutid,'itrt',rcode)
call ncvpt1(ncoutid,varid,1,itrt,rcode)
c
c Shapiro filter order and number of applications.
c
varid=ncvid(ncoutid,'nord',rcode)
call ncvpt1(ncoutid,varid,1,nord,rcode)
varid=ncvid(ncoutid,'nfrq',rcode)
call ncvpt1(ncoutid,varid,1,nfrq,rcode)
c
c Parameters used in computation of dynamic height.
c
if(ldynht) then
varid=ncvid(ncoutid,'zref',rcode)
call ncvpt1(ncoutid,varid,1,zref,rcode)
varid=ncvid(ncoutid,'idhopt',rcode)
call ncvpt1(ncoutid,varid,1,idhopt,rcode)
endif
c
c Write out depths at the middle of the grid vertical boxes.
c
start(1)=zindx
count(1)=1
start(2)=1
count(2)=nlev
do 30 n=1,nlev
wrk(n)=-abs(z(n))
30 continue
varid=ncvid(ncoutid,'zout',rcode)
call ncvpt(ncoutid,varid,start,count,wrk,rcode)
if(rcode.ne.0) then
write(iprt,901) 'zout'
call exitus('DEFCDF')
endif
c
c Write (x,y) positions for 2D fields.
c
if(lmsk) then
start(1)=xindx
count(1)=1
start(2)=1
count(2)=im
start(3)=1
count(3)=jm
call ncvpt(ncoutid,g2did,start,count,lon,rcode)
if(rcode.ne.0) then
write(iprt,901) 'grid2 x-axis'
call exitus('DEFCDF')
endif
start(1)=yindx
count(1)=1
call ncvpt(ncoutid,g2did,start,count,lat,rcode)
if(rcode.ne.0) then
write(iprt,901) 'grid2 y-axis'
call exitus('DEFCDF')
endif
endif
c
c Write (x,y) positions for 3D fields.
c
start(1)=xindx
count(1)=1
start(2)=1
count(2)=im
start(3)=1
count(3)=jm
call ncvpt(ncoutid,g3did,start,count,lon,rcode)
if(rcode.ne.0) then
write(iprt,901) 'grid3 x-axis'
call exitus('DEFCDF')
endif
start(1)=yindx
count(1)=1
call ncvpt(ncoutid,g3did,start,count,lat,rcode)
if(rcode.ne.0) then
write(iprt,901) 'grid3 y-axis'
call exitus('DEFCDF')
endif
c
c Write out Land/Sea mask data.
c
if(lmsk) then
start(1)=1
count(1)=im
start(2)=1
count(2)=jm
call ncvpt(ncoutid,mskid,start,count,landt,rcode)
if(rcode.ne.0) then
write(iprt,901) 'mask'
call exitus('DEFCDF')
endif
endif
c
900 format(/' DEFCDF - unable to create output NetCDF file: ',a)
901 format(/' DEFCDF - error while writing variable: ',a,2x,
* ' into output NetCDF file.')
return
end
#*************************************************************************
# *
# GNUmakefile.iris: *
# *
# Script to compile and link the generalized space-time objective *
# analysis/statistical forecast package (OA). *
# *
# This makefile is written for GNU Make, version 3.75 *
# *
# Free Software Foundation (617) 876-3296 *
# 675 Mass Ave. gnu@xxxxxxxxxxxxxxx *
# Cambridge, MA 02139, USA http://www.gnu.ai.mit.edu/ *
# *
# It is NOT compatible with the standard UNIX Make. *
# *
# Executable: *
# *
# oa Objectively analize data (locally). (default) *
# *
# GNUmake targets: *
# *
# clean Remove all intermediate files. *
# *
# This makefile has been designed to allow the user to compile the OA *
# source codes in a separate directory from that in which the source *
# codes are located. The makefile searches for the code segments in *
# the following alternate paths: *
# *
# source code: (1) the directory containing this GNUmakefile. *
# (2) the directory specified by the macro SRCDIR *
# *
# include files: (1) the directory containing this GNUmakefile. *
# (2) the directory specified by the macro PARAMDIR *
# (3) the directory specified by the macro SRCDIR *
# (4) the directory specified by the macro NCDIR *
# *
# This provides the user with the flexibility for the following *
# configurations: *
# *
# (1) The user needs only copies of this GNUmakefile, the parameter *
# file "param.h" and a path to the source codes to produce a *
# version of OA with the appropriate C-preprocessing and *
# compilier options. *
# *
# (2) The user who is modifying the OA code, can isolate those *
# routines actually being changed with a copy of this GNUmakefile *
# in a sub-directory. *
# *
# Patrick J. Haley Jr. 01/23/2001 *
# OA package Version 6.6 *
# *
#*************************************************************************
#************************ USER's tunable macros **************************
#*************************************************************************
#
# BIN name of the executable code
# BINDIR directory path for executable code
# CPPFLAGS C-preprocessing flags and options
# FFLAGS flags for the fortran compiler
# NCDIR directory path for NetCDF include files
# PARAMDIR directory path for include files
# SRCDIR directory path for source codes
#
#*************************************************************************
#
# C-preprocessing options:
#
# -Daixdate AIX intrinsic date routine (IBM RS6000).
# -Dcraydate CRAY's intrinsic date routine.
# -Ddecdate DEC's VMS intrinsic date routine.
# -Dgendbg Generic Debugging: Preserves intermediate files
# -Drmcomments Remove comments when pre-processing.
# -Dsundate SUN's intrinsic date routine.
# -Dsunflush regularly flush output buffers in SUN systems.
# -Dsunfpe enable SUN's Floating Point Exception trap.
#
#************************************************************************
SRCDIR = .
PARAMDIR = .
NCDIR = $(NETCDF_ROOT)/include
BINDIR = .
BIN = oa
CPPFLAGS = -Dsundate
FFLAGS = $(OSFLAG) -u -O
#************************************************************************
#******************** End of USER's tunable macros **********************
#************************************************************************
#------------------------------------------------------------------------
#--------------------- Internal macro definitions. ----------------------
#------------------------------------------------------------------------
RMBLKLINES = rmblklines
SHELL = /bin/sh
RM = rm -f
ECHO = echo
FALSE = false
LIB = -L$(NETCDF_ROOT)/lib -lnetcdf
CPP = /usr/lib/acpp -P -I. -I$(PARAMDIR) -I$(SRCDIR) -I$(NCDIR)
FC = f77
#------------------------------------------------------------------------
#---------------- Look for bad C Pre-Processing Flags. ------------------
#------------------------------------------------------------------------
VALID_CPP_OPT = -Daixdate -Dcraydate -Ddecdate -Dgendbg -Drmcomments \
-Dsundate -Dsunflush -Dsunfpe
INVALID_CPP_OPT = $(strip $(filter-out $(VALID_CPP_OPT),$(CPPFLAGS)))
#------------------------------------------------------------------------
#--------------------- Redefine compiling macros. -----------------------
#------------------------------------------------------------------------
MAKEFLAGS := -r $(MAKEFLAGS)
.SUFFIXES:
.SUFFIXES: .o .f .F .FF
%.o: %.f
-$(FC) -c $(FFLAGS) -o $*.o $*.f
%.o: %.F
%.o: %.FF
%.f: %.F
-$(CPP) $(CPPFLAGS) $< ./$*.cpp
-./$(RMBLKLINES) < $*.cpp > $*.f
-$(RM) $*.cpp
%.f: %.FF
-$(CPP) $(CPPFLAGS) $< ./$*.f
#------------------------------------------------------------------------
#-------------- Define alternate paths for source codes. ----------------
#------------------------------------------------------------------------
#--------------------------
#--- Define source path ---
#--------------------------
testpath = .
pathstr =
ifeq (,$(strip $(filter $(SRCDIR),$(subst :, ,$(testpath)))))
testpath := $(testpath):$(SRCDIR)
pathstr := $(SRCDIR)
endif
ifneq (,$(pathstr))
vpath %.F $(pathstr)
vpath %.FF $(pathstr)
endif
#---------------------------
#--- Define include path ---
#---------------------------
ifeq (,$(strip $(filter $(PARAMDIR),$(subst :, ,$(testpath)))))
testpath := $(PARAMDIR):$(testpath)
ifneq (,$(pathstr))
pathstr := $(PARAMDIR):$(pathstr)
else
pathstr := $(PARAMDIR)
endif
endif
ifeq (,$(strip $(filter $(NCDIR),$(subst :, ,$(testpath)))))
testpath := $(testpath):$(NCDIR)
ifneq (,$(pathstr))
pathstr := $(pathstr):$(NCDIR)
else
pathstr := $(NCDIR)
endif
endif
ifneq (,$(pathstr))
vpath %.h $(pathstr)
vpath %.inc $(pathstr)
endif
#------------------------------------------------------------------------
#-------- Define string macro to parse C Pre-Processing Flags. ----------
#------------------------------------------------------------------------
find_flag = $(findstring $(flag),$(CPPFLAGS))
#------------------------------------------------------------------------
#------- Preserve intermediate source codes only when debugging. --------
#------------------------------------------------------------------------
dbg_flags = sunfpe gendbg
ifneq (,$(strip $(foreach flag,$(dbg_flags),$(find_flag))))
.PRECIOUS: %.f
endif
#------------------------------------------------------------------------
#--- Declare "phony" targets. GNUmake can always run these targets. ----
#------------------------------------------------------------------------
ifeq (,$(INVALID_CPP_OPT))
.PHONY: clean
else
.PHONY: clean $(BIN)
endif
#------------------------------------------------------------------------
#---------------------------- Source Codes. -----------------------------
#------------------------------------------------------------------------
SRCS = oamain.F \
acor.F asm.F bes1d.F bes2d.F \
blkdat.F caldate.F defcdf.F dhlev.F \
diagn.F down_shift.F dynht.F errscl.F \
exitus.F filter.F gcircle.F getclima.F \
get_date.F getdynht.F get_ewpt.F getobs.F \
gregorian.F headln.F ierinv.F indepen.F \
invmtx.F length.F lintrp.F ll2xy.F \
lnblk.F locate.F lubksb.F ludcmp.F \
nxt_blnk.F oamean.F oapar.F objan.F \
outlier.F qtrap.F readgrids.F readhydro.F \
remove.F rotparm.F rout_chk.F select.F \
set_type.F sort.F svafunc.F svan.F \
svel.F trapzd.F trend.F trendcoef.F \
xclima.F xhydro.F xy2ll.F
DAYSRC = day_code.F
DBGSRC = my_handler.F
#------------------------------------------------------------------------
#--------------------------- Active Objects. ----------------------------
#------------------------------------------------------------------------
OBJS = $(SRCS:.F=.o)
day_flags = craydate decdate
ifneq (,$(strip $(foreach flag,$(day_flags),$(find_flag))))
OBJS := $(OBJS) $(DAYSRC:.F=.o)
endif
ifneq (,$(findstring sunfpe,$(CPPFLAGS)))
OBJS := $(OBJS) $(DBGSRC:.F=.o)
endif
#------------------------------------------------------------------------
#------------------------ Create OA executable. -------------------------
#------------------------------------------------------------------------
ifeq (,$(INVALID_CPP_OPT))
$(BIN): $(RMBLKLINES) $(OBJS)
@($(ECHO) "";\
$(ECHO) "Creating OA executable:" ;\
$(ECHO) "" )
$(FC) $(FFLAGS) -o $(BINDIR)/$(BIN) $(OBJS) $(LIB)
else
$(BIN):
@($(ECHO) "";\
$(ECHO) "***********************************" ;\
$(ECHO) "*** Invalid CPP options present ***" ;\
$(ECHO) "***********************************" ;\
$(ECHO) "" ;\
$(ECHO) "$(INVALID_CPP_OPT)" ;\
$(ECHO) "" ;\
$(ECHO) "***********************************" ;\
$(ECHO) "*** No compilation will be done ***" ;\
$(ECHO) "***********************************" ;\
$(ECHO) "" ;\
$(FALSE) )
endif
#------------------------------------------------------------------------
#---------------- Create remove blank lines executable. -----------------
#------------------------------------------------------------------------
$(RMBLKLINES): rmblklines.o
@($(ECHO) "";\
$(ECHO) "Making post-processing code $(RMBLKLINES):";\
$(ECHO) "" )
$(FC) $(FFLAGS) -o $(RMBLKLINES) rmblklines.o
@($(ECHO) "" )
#------------------------------------------------------------------------
#--------- Target for cleaning preprocessed and object files. -----------
#------------------------------------------------------------------------
clean:
@$(RM) *.f *.o $(RMBLKLINES)
#------------------------------------------------------------------------
#------------- Set dependencies for C-preprocessed files. ---------------
#------------------------------------------------------------------------
acor.f: corscl.h
blkdat.f: param.h inppar.h version.h \
oa_netcdf.h
defcdf.f: param.h clima.h corscl.h \
domdat.h hydobs.h inppar.h \
netcdf.inc oagrid.h oa_netcdf.h \
obscor.h version.h
diagn.f: date.h fdiagn.h
dynht.f: trapz.h param.h
exitus.f: param.h inppar.h oa_netcdf.h
filter.f: param.h
getclima.f: param.h clima.h domdat.h \
hydobs.h hydro.h oagrid.h
getdynht.f: param.h
getobs.f: param.h domdat.h hydobs.h \
hydro.h oagrid.h
headln.f: version.h
indepen.f: param.h corscl.h
oamain.f: param.h clima.h fdiagn.h \
hydobs.h inppar.h oagrid.h \
oa_netcdf.h obscor.h
oamean.f: param.h corscl.h domdat.h \
oagrid.h
oapar.f: param.h clima.h corscl.h \
debug.h domdat.h hydobs.h \
inppar.h oagrid.h obscor.h
objan.f: param.h debug.h obscor.h
outlier.f: param.h debug.h domdat.h \
oagrid.h
readgrids.f: param.h domdat.h inppar.h \
netcdf.inc oagrid.h oa_netcdf.h
readhydro.f: hydro.h param.h
rout_chk.f: param.h domdat.h oagrid.h
select.f: param.h corscl.h debug.h \
obscor.h
set_type.f: param.h hydro.h
svafunc.f: trapz.h param.h
trend.f: trdcff.h
trendcoef.f: param.h
xclima.f: param.h clima.h hydobs.h \
oa_netcdf.h
xhydro.f: param.h hydobs.h oa_netcdf.h