diff --git a/.gitignore b/.gitignore index 948c679040f7ea21366a139dd55d3a3a5593230d..fff9635901acfebe93ff008cb9eae743ad3c3c43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .*.sw* .idea +*.o +*.mod diff --git a/interpolation/rotateUVorca_sources/makefile b/interpolation/rotateUVorca_sources/makefile index bcc4471038a8f61ef895a31d96ebb7e0686cd82d..17b9c41bef7b8f8aabfbcfe30f2ccd0e4554c829 100755 --- a/interpolation/rotateUVorca_sources/makefile +++ b/interpolation/rotateUVorca_sources/makefile @@ -1,7 +1,7 @@ #!/bin/csh # COMPILE = gfortran -FLAGS = -O3 -I/usr/include -L/usr/lib +FLAGS = -Og -g -I$(EBROOTNETCDFMINFORTRAN)/include -L$(EBROOTNETCDFMINFORTRAN)/lib LIB = -lnetcdf -lnetcdff INCLUDE = SRCDIR = . diff --git a/interpolation/rotateUVorca_sources/par_kind.f90 b/interpolation/rotateUVorca_sources/par_kind.f90 index d5d336212e2ef1ff7fa38db940d311d1620ff7c6..aa875bba6a5e8bbc77145403dedc9f1199beff0b 100755 --- a/interpolation/rotateUVorca_sources/par_kind.f90 +++ b/interpolation/rotateUVorca_sources/par_kind.f90 @@ -38,11 +38,11 @@ MODULE par_kind i4 = KIND(1) , & !: single precision (integer 4) i8 = KIND(1) !: double precision (integer 8) - INTEGER , PUBLIC, PARAMETER :: jpi = 1442 + INTEGER , PUBLIC, PARAMETER :: jpi = 362 INTEGER , PUBLIC, PARAMETER :: jpim1 = jpi-1 - INTEGER , PUBLIC, PARAMETER :: jpj = 1021 + INTEGER , PUBLIC, PARAMETER :: jpj = 292 INTEGER , PUBLIC, PARAMETER :: jpk = 2 - INTEGER , PUBLIC, PARAMETER :: jpiglo = 1442 + INTEGER , PUBLIC, PARAMETER :: jpiglo = 362 INTEGER , PUBLIC, PARAMETER :: jpni =1 !!---------------------------------------------------------------------- diff --git a/interpolation/rotateUVorca_sources/rotateUVorca.f90 b/interpolation/rotateUVorca_sources/rotateUVorca.f90 index b3711c992fe04c0152480bc9185e03ae9215a687..12a6da70a5ca745e5139c75587eada205e85872a 100755 --- a/interpolation/rotateUVorca_sources/rotateUVorca.f90 +++ b/interpolation/rotateUVorca_sources/rotateUVorca.f90 @@ -24,7 +24,8 @@ program rotateUVorca & Vvarin, & ! name of the Northward component & meshmask, & ! name of the meshmask & Ufileout, & ! U output file - & Vfileout ! V output file + & Vfileout, & ! V output file + & config_file ! namelist filename integer :: nc_fileU_id, nc_fileV_id, nc_filemask_id, nc_varU_id, & & nc_varV_id, nc_time_id, nc_var_type, nc_outfile_id, ncstat, & @@ -52,9 +53,13 @@ program rotateUVorca ! ! Read namelist ! -!============================================================================== +!============================================================================== ! - open(80, file='namelist_rotateUVorca', status='old', form='formatted') + call getarg(1, config_file) + if (config_file == '') then + config_file = 'namelist_rotateUVorca' + endif + open(80, file=config_file, status='old', form='formatted') read(80, nml=nam_rotUV) write(*,nml=nam_rotUV) ! diff --git a/interpolation/scrip_sources/makefile b/interpolation/scrip_sources/makefile index 1bc6767233e5160a95ef3d6c04271a2be6f22a96..47169073ee02d745a3749a8f2823a7057db6dc06 100755 --- a/interpolation/scrip_sources/makefile +++ b/interpolation/scrip_sources/makefile @@ -5,7 +5,7 @@ # CVS:$Id: makefile,v 1.7 2000/04/19 21:46:44 pwjones Exp $ # COMPILE = gfortran -FLAGS = -O3 -I/usr/include -L/usr/lib +FLAGS = -O3 -I/shared/earth/software/netCDF-Fortran/4.2-foss-2015a/include -L/shared/earth/software/netCDF-Fortran/4.2-foss-2015a/lib LIB = -lnetcdf -lnetcdff INCLUDE = SRCDIR = . diff --git a/interpolation/scrip_sources/remap_read.f b/interpolation/scrip_sources/remap_read.f index 7501b46af6d16a26246dca34c2a4c02d41b6c727..e474d1b5619ef536fa25945c95d88e3b843679b2 100755 --- a/interpolation/scrip_sources/remap_read.f +++ b/interpolation/scrip_sources/remap_read.f @@ -125,7 +125,8 @@ ! open file and read some global information ! !----------------------------------------------------------------------- - + print *, 'opening file and reading global information' + print *,'From file:',trim(interp_file) ncstat = nf_open(interp_file, NF_NOWRITE, nc_file_id) call netcdf_error_handler(ncstat) @@ -137,8 +138,7 @@ & map_name) call netcdf_error_handler(ncstat) - print *,'Reading remapping:',trim(map_name) - print *,'From file:',trim(interp_file) + !*** !*** normalization option @@ -267,7 +267,7 @@ ! read dimension information ! !----------------------------------------------------------------------- - + ncstat = nf_inq_dimid(nc_file_id, 'src_grid_size', & nc_srcgrdsize_id) call netcdf_error_handler(ncstat) @@ -356,7 +356,7 @@ ! get variable ids ! !----------------------------------------------------------------------- - + print *,'get variable ids ' ncstat = nf_inq_varid(nc_file_id, 'src_grid_dims', & nc_srcgrddims_id) call netcdf_error_handler(ncstat) @@ -438,28 +438,27 @@ ! read all variables ! !----------------------------------------------------------------------- - + print *,'read all variables' ncstat = nf_get_var_int(nc_file_id, nc_srcgrddims_id, & grid1_dims) call netcdf_error_handler(ncstat) - + print *,'read srcgrdimask' ncstat = nf_get_var_int(nc_file_id, nc_srcgrdimask_id, & grid1_mask_int) call netcdf_error_handler(ncstat) - + print *,'read srcgrdcntrlat' ncstat = nf_get_var_double(nc_file_id, nc_srcgrdcntrlat_id, & grid1_center_lat) call netcdf_error_handler(ncstat) - + print *,'read srcgrdcntrlon' ncstat = nf_get_var_double(nc_file_id, nc_srcgrdcntrlon_id, & grid1_center_lon) call netcdf_error_handler(ncstat) - + print *,'read srcgrdcrnrlat' grid1_units = ' ' - ncstat = nf_get_att_text(nc_file_id, nc_srcgrdcntrlat_id, 'units', + ncstat = nf_get_att_text(nc_file_id, nc_srcgrdcrnrlat_id, 'units', & grid1_units) call netcdf_error_handler(ncstat) - select case (grid1_units(1:7)) case ('degrees') grid1_center_lat = grid1_center_lat*deg2rad @@ -470,15 +469,15 @@ print *,'unknown units supplied for grid1 center lat/lon: ' print *,'proceeding assuming radians' end select - + print *,'read srcgrdcrnrlat' ncstat = nf_get_var_double(nc_file_id, nc_srcgrdcrnrlat_id, & grid1_corner_lat) call netcdf_error_handler(ncstat) - + print *,'read srcgrdcrnrlon' ncstat = nf_get_var_double(nc_file_id, nc_srcgrdcrnrlon_id, & grid1_corner_lon) call netcdf_error_handler(ncstat) - + print *,'read srcgrdcrnrlat' grid1_units = ' ' ncstat = nf_get_att_text(nc_file_id, nc_srcgrdcrnrlat_id, 'units', & grid1_units) @@ -542,7 +541,7 @@ ncstat = nf_get_var_double(nc_file_id, nc_dstgrdcrnrlon_id, & grid2_corner_lon) call netcdf_error_handler(ncstat) - + print *,'reading dstgrdcrnrlat' grid2_units = ' ' ncstat = nf_get_att_text(nc_file_id, nc_dstgrdcrnrlat_id, 'units', & grid2_units) @@ -558,23 +557,25 @@ print *,'unknown units supplied for grid2 corner lat/lon: ' print *,'proceeding assuming radians' end select - + print *,'reading dstgrdarea' ncstat = nf_get_var_double(nc_file_id, nc_dstgrdarea_id, & grid2_area) call netcdf_error_handler(ncstat) - + print *,'reading dstgrdfrac' ncstat = nf_get_var_double(nc_file_id, nc_dstgrdfrac_id, & grid2_frac) call netcdf_error_handler(ncstat) - + print *,'reading srcgrdadd', nc_file_id + print *, nc_srcgrdadd_id + print *, grid1_add_map1 ncstat = nf_get_var_int(nc_file_id, nc_srcgrdadd_id, & grid1_add_map1) call netcdf_error_handler(ncstat) - + print *,'reading dstgrdadd' ncstat = nf_get_var_int(nc_file_id, nc_dstgrdadd_id, & grid2_add_map1) call netcdf_error_handler(ncstat) - + print *,'reading rmpmatrix' ncstat = nf_get_var_double(nc_file_id, nc_rmpmatrix_id, & wts_map1) call netcdf_error_handler(ncstat) @@ -584,7 +585,7 @@ ! initialize logical mask ! !----------------------------------------------------------------------- - + print *, 'initialize logical mask' where (grid1_mask_int == 1) grid1_mask = .true. elsewhere @@ -602,7 +603,7 @@ ! close input file ! !----------------------------------------------------------------------- - + print *, 'close input file' ncstat = nf_close(nc_file_id) call netcdf_error_handler(ncstat) diff --git a/interpolation/scrip_sources/scrip_use.f b/interpolation/scrip_sources/scrip_use.f index 5dee826fc9f796850a8628e5d97c5ca444937da6..eacf7dffc73570db123cbd0baffea94ae2915d31 100755 --- a/interpolation/scrip_sources/scrip_use.f +++ b/interpolation/scrip_sources/scrip_use.f @@ -4,7 +4,7 @@ ! using the interpolation weights computed by SCRIP : ! Spherical Coordinate Remapping and Interpolation Package ! -! The arguments are passed through a namelist named scrip_use_in: +! The arguments are passed through a namelist named: !&remap_inputs ! remap_wgt = 'Weights from SCRIP' ! infile = 'input netcdf file' @@ -13,8 +13,12 @@ ! fromregular = TRUE/FALSE : is the input grid regular ? ! outfile = 'output netcdf file' !/ +! By default, this namelist is called scrip_use_in but another file can be +! provided as the first argument +! ! ! History : Virginie Guemas - Initial version - 2011 +! Javier Vegas - Added argument for namelist filename - 2016 !----------------------------------------------------------------------- program scrip_use @@ -43,7 +47,8 @@ & remap_wgt, ! filename containing remap data (map1) & infile, ! filename containing input field & var, ! var name in infile - & outfile ! filename to output interpolated field + & outfile, ! filename to output interpolated field + & config_file ! namelist filename logical :: fromregular @@ -104,7 +109,13 @@ !----------------------------------------------------------------------- call get_unit(iunit) - open(iunit, file='scrip_use_in', status='old', form='formatted') + + call getarg(1, config_file) + if (config_file == '') then + config_file = 'scrip_use_in' + endif + + open(iunit, file=config_file, status='old', form='formatted') read(iunit, nml=remap_inputs) call release_unit(iunit) write(*,nml=remap_inputs) @@ -114,7 +125,7 @@ ! read remapping data ! !----------------------------------------------------------------------- - + print *, 'reading remapping data...' call read_remap(map_name, remap_wgt) !----------------------------------------------------------------------- @@ -122,7 +133,7 @@ ! read input file ! !----------------------------------------------------------------------- - + print *, 'reading input file...' call read_input(infile, var) !----------------------------------------------------------------------- @@ -130,7 +141,7 @@ ! allocate arrays ! !----------------------------------------------------------------------- - + print *, 'allocating arrays...' allocate (grid1_tmp (grid1_size), & grad1_lat (grid1_size), & grad1_lon (grid1_size), @@ -161,7 +172,7 @@ ! setup a NetCDF file for output ! !----------------------------------------------------------------------- - + print *, 'preparing netCDF file for output...' !*** !*** create netCDF dataset !*** @@ -176,6 +187,7 @@ !*** !*** define grid size dimensions !*** + print *, 'Define grid size dimensions' allocate( nc_grid2size_id(grid2_rank+1)) allocate( nc_grid1size_id(grid1_rank+1)) @@ -201,6 +213,7 @@ !*** !*** Create time dimension !*** + print *, 'Create time dimension' ncstat = nf_def_dim (nc_outfile_id, 'time', & NF_UNLIMITED, nc_grid2size_id(3)) @@ -228,7 +241,8 @@ !*** !*** define grid center latitude array !*** - + print *, 'define grid center latitude array' + ncstat = nf_def_var (nc_outfile_id, 'latitude', & NF_DOUBLE, grid2_rank, nc_grid2size_id & (1:grid2_rank), nc_dstgrdcntrlat_id) @@ -241,6 +255,7 @@ !*** !*** define grid center longitude array !*** + print *, 'define grid center longitude array' ncstat = nf_def_var (nc_outfile_id, 'longitude', & NF_DOUBLE, grid2_rank, nc_grid2size_id @@ -254,6 +269,7 @@ !*** !*** define source array !*** + print *, 'Define source array' ncstat = nf_def_var (nc_outfile_id, 'input', & NF_DOUBLE, (grid1_rank+1), nc_grid1size_id, @@ -265,6 +281,7 @@ !*** !*** define destination arrays !*** + print *, 'Define destination arrays' ncstat = nf_def_var (nc_outfile_id, var, & NF_DOUBLE, ( grid2_rank + 1 ), @@ -274,6 +291,7 @@ & 'missing_value', NF_DOUBLE,1,dble(1e20)) call netcdf_error_handler(ncstat) + if ( nvaratts >= 1 ) then do jatt = 1,nvaratts ncstat = nf_inq_attname(nc_infile_id, nc_invar_id, jatt, @@ -282,6 +300,7 @@ if ((attname .ne. '_FillValue') .and. (attname .ne. & 'missing_value') ) then + print *, 'Copying attribute ', attname ncstat = nf_copy_att(nc_infile_id, nc_invar_id, attname, & nc_outfile_id, nc_dstarray1_id) call netcdf_error_handler(ncstat) @@ -291,6 +310,7 @@ if ( nglobatts >= 1 ) then do jatt = 1,nglobatts + print *, 'Copying global attribute ', attname ncstat = nf_inq_attname(nc_infile_id, NF_GLOBAL, jatt, & attname) call netcdf_error_handler(ncstat) @@ -301,7 +321,7 @@ enddo endif - + print *, 'Closing file ', attname ncstat = nf_close(nc_infile_id) call netcdf_error_handler(ncstat) @@ -317,7 +337,7 @@ ! write some grid info ! !----------------------------------------------------------------------- - + print *, 'writing grid info' !*** !*** write grid center latitude array !*** @@ -339,6 +359,7 @@ ! Interpolate the input mask ! !----------------------------------------------------------------------- + print *, 'Interpolating the input mask' call remap(grid1_mask_grid2, wts_map1, grid2_add_map1, & grid1_add_map1, real(grid1_imask,kind=dbl_kind)) @@ -347,7 +368,7 @@ ! Write time dimension ! !----------------------------------------------------------------------- - + print *, 'Write time dimension' do jtime = 1,ntime ncstat = nf_put_vara_double(nc_outfile_id, nc_vartime_id, @@ -359,7 +380,7 @@ ! if bicubic or 2nd-order conservative, 3 gradients needed in space ! !----------------------------------------------------------------------- - + if ( fromregular .and. (map_type == map_type_bicubic .or. & map_type == map_type_conserv) ) then @@ -577,7 +598,7 @@ ! write results to NetCDF file ! !----------------------------------------------------------------------- - + print *, 'Writinf results...' where (grid2_imask<0.5 .or. grid1_mask_grid2 == 0. ) grid2_tmp=1e20 end where @@ -604,6 +625,7 @@ ncstat = nf_close(nc_outfile_id) call netcdf_error_handler(ncstat) + print *, 'Done!' !-----------------------------------------------------------------------